Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在没有Android应用程序验证的情况下,我应该如何设置OAuth同意屏幕?_Android_Google Api_Google Fit_Google Fit Sdk - Fatal编程技术网

在没有Android应用程序验证的情况下,我应该如何设置OAuth同意屏幕?

在没有Android应用程序验证的情况下,我应该如何设置OAuth同意屏幕?,android,google-api,google-fit,google-fit-sdk,Android,Google Api,Google Fit,Google Fit Sdk,我正在开发一个Android应用程序,它使用GoogleFitAPI。我已经启用了它,它提供了客户端id和API密钥。 我应该如何设置OAuth屏幕 我的应用程序使用会话API记录数据,使用历史API查看以前存储的数据。目前,我能够记录可以在Google Fit应用程序中查看的活动数据,但当我使用历史API时,我遇到了这个错误 com.google.android.gms.common.api.ApiException: 5000: Application needs OAuth consent

我正在开发一个Android应用程序,它使用GoogleFitAPI。我已经启用了它,它提供了客户端id和API密钥。 我应该如何设置OAuth屏幕

我的应用程序使用会话API记录数据,使用历史API查看以前存储的数据。目前,我能够记录可以在Google Fit应用程序中查看的活动数据,但当我使用历史API时,我遇到了这个错误

com.google.android.gms.common.api.ApiException: 5000: Application needs OAuth consent from the user
我想检查API的功能只是为了演示,所以应用程序不需要验证。我应该如何设置同意屏幕或请求用户同意
我是否需要对敏感范围(如活动读写)进行验证

  • 检查您是否正在请求具有相关读/写权限的正确作用域:
  • 检查您是否未尝试读取您无权访问的作用域:
  • i、 e.更改响应中下面的数据类型
    数据类型。聚合\u步骤\u计数\u增量

    private fun accessGoogleFit() {
        val end = LocalDateTime.now()
        val start = end.minusYears(1)
        val endSeconds = end.atZone(ZoneId.systemDefault()).toEpochSecond()
        val startSeconds = start.atZone(ZoneId.systemDefault()).toEpochSecond()
    
        val readRequest = DataReadRequest.Builder()
            .aggregate(DataType.AGGREGATE_STEP_COUNT_DELTA)
            .setTimeRange(startSeconds, endSeconds, TimeUnit.SECONDS)
            .bucketByTime(1, TimeUnit.DAYS)
            .build()
        val account = GoogleSignIn.getAccountForExtension(this, fitnessOptions)
        Fitness.getHistoryClient(this, account)
            .readData(readRequest)
            .addOnSuccessListener({ response ->
                // Use response data here
                Log.i(TAG, "OnSuccess()")
            })
            .addOnFailureListener({ e -> Log.d(TAG, "OnFailure()", e) })
    }
    

    谢谢你的解决方案
    private fun accessGoogleFit() {
        val end = LocalDateTime.now()
        val start = end.minusYears(1)
        val endSeconds = end.atZone(ZoneId.systemDefault()).toEpochSecond()
        val startSeconds = start.atZone(ZoneId.systemDefault()).toEpochSecond()
    
        val readRequest = DataReadRequest.Builder()
            .aggregate(DataType.AGGREGATE_STEP_COUNT_DELTA)
            .setTimeRange(startSeconds, endSeconds, TimeUnit.SECONDS)
            .bucketByTime(1, TimeUnit.DAYS)
            .build()
        val account = GoogleSignIn.getAccountForExtension(this, fitnessOptions)
        Fitness.getHistoryClient(this, account)
            .readData(readRequest)
            .addOnSuccessListener({ response ->
                // Use response data here
                Log.i(TAG, "OnSuccess()")
            })
            .addOnFailureListener({ e -> Log.d(TAG, "OnFailure()", e) })
    }