我想在 Google API JavaScript 中使用多个范围。 我要做的是获取用户的电子邮件和姓名。
我可以从范围中获得的名称:https://www.googleapis.com/auth/plus.me
我可以从范围中获得的电子邮件:https://www.googleapis.com/auth/userinfo.email
但是如何在同一个应用程序中同时使用它们呢?
我的代码是:
scopes = 'https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/userinfo.email';
gapi.signin.render('StartGoogleBtn', {
'callback': 'onSignInCallback',
'clientid': clientId,
'cookiepolicy': 'single_host_origin',
'scope': scopes
});
应该是什么范围?谢谢:)
最佳答案
只是猜测,但请尝试用双引号括起来的空格分隔。这就是 OAuth 2 所要求的,当我为客户端编写代码时,我让它自动正确地处理该场景。我假设它只是通过命令传递。这对我有用。
scopes = "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/plus.me"
关于javascript - Google API 多作用域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25964327/