我使用 Google API 登录 Android 应用。
代码在这里:
SignInButton btnLogin = (SignInButton) findViewById(R.id.sign_in_button);
btnLogin.setOnClickListener(this);
Scope[] scopes = new Scope[2];
scopes[0] = new Scope("https://www.googleapis.com/auth/admin.directory.user.readonly");
scopes[1] = new Scope("https://www.googleapis.com/auth/contacts.readonly");
btnLogin.setScopes(scopes);
使用访问 token 登录成功,但访问 token 只有默认范围:
"userinfo.profile" & "userinfo.email" & "auth/plus.me"
你能帮我拿两个瞄准镜吗:
"/auth/admin.directory.user.readonly" & "/auth/contacts.readonly"
最佳答案
可以引用如下语法:
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestScopes(new Scope(Scopes.PLUS_LOGIN)) // "https://www.googleapis.com/auth/plus.login"
.requestScopes(new Scope(Scopes.PLUS_ME)) // "https://www.googleapis.com/auth/plus.me"
.requestEmail()
.build();
更多详情请访问 this documentation .希望对您有所帮助!
关于android - 无法在 Android 上设置范围 Google 登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34690310/