在没有Android应用程序验证的情况下,我应该如何设置OAuth同意屏幕?
我正在开发一个Android应用程序,它使用GoogleFitAPI。我已经启用了它,它提供了客户端id和API密钥。 我应该如何设置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
我的应用程序使用会话API记录数据,使用历史API查看以前存储的数据。目前,我能够记录可以在Google Fit应用程序中查看的活动数据,但当我使用历史API时,我遇到了这个错误
com.google.android.gms.common.api.ApiException: 5000: Application needs OAuth consent from the user
我想检查API的功能只是为了演示,所以应用程序不需要验证。我应该如何设置同意屏幕或请求用户同意我是否需要对敏感范围(如活动读写)进行验证
数据类型。聚合\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) })
}