使用 GoogleSignInOptions for Tasks 请求范围 API
Request scopes with GoogleSignInOptions for Tasks API
我已经在我的 Android 应用程序中设置 Google 登录。根据 Google 开发人员的说法,请求 API 的范围应该很简单:
if (!GoogleSignIn.hasPermissions(
GoogleSignIn.getLastSignedInAccount(getActivity()),
TasksScopes.TASKS)) {
GoogleSignIn.requestPermissions(
MyExampleActivity.this,
RC_REQUEST_PERMISSION_SUCCESS_CONTINUE_FILE_CREATION,
GoogleSignIn.getLastSignedInAccount(getActivity()),
TasksScopes.TASKS);
} else {
saveToDriveAppFolder();
}
"...call GoogleSignIn.requestPermissions to launch an activity that requests the additional required scopes from the user." https://developers.google.com/identity/sign-in/android/additional-scopes
或
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestScopes(TasksScopes.TASKS)
.build();
If you need to request additional scopes to access Google APIs,
specify them with requestScopes https://developers.google.com/identity/sign-in/android/additional-scopes
但是,Tasks API 出现错误 "requestScopes in Builder cannot be applies to java.lang.String"。
我也试过复制这个sample piece of code
P.S。 Google 登录功能的其余部分正常工作。
原来如此简单...
'Scope scope = new Scope("scopeurl")'
Scope url 来自 Google Developers Oauth Scopes page.
我已经在我的 Android 应用程序中设置 Google 登录。根据 Google 开发人员的说法,请求 API 的范围应该很简单:
if (!GoogleSignIn.hasPermissions(
GoogleSignIn.getLastSignedInAccount(getActivity()),
TasksScopes.TASKS)) {
GoogleSignIn.requestPermissions(
MyExampleActivity.this,
RC_REQUEST_PERMISSION_SUCCESS_CONTINUE_FILE_CREATION,
GoogleSignIn.getLastSignedInAccount(getActivity()),
TasksScopes.TASKS);
} else {
saveToDriveAppFolder();
}
"...call GoogleSignIn.requestPermissions to launch an activity that requests the additional required scopes from the user." https://developers.google.com/identity/sign-in/android/additional-scopes
或
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestScopes(TasksScopes.TASKS)
.build();
If you need to request additional scopes to access Google APIs, specify them with requestScopes https://developers.google.com/identity/sign-in/android/additional-scopes
但是,Tasks API 出现错误 "requestScopes in Builder cannot be applies to java.lang.String"。
我也试过复制这个sample piece of code
P.S。 Google 登录功能的其余部分正常工作。
原来如此简单...
'Scope scope = new Scope("scopeurl")'
Scope url 来自 Google Developers Oauth Scopes page.