问题描述
如何在oauth2操场用户界面的“范围”输入框中输入多个范围? 我正在尝试使用以下链接生成身份验证/刷新令牌:https://developers.google.com/oauthplayground
我在选择API范围时找不到所需的范围: https://www.googleapis.com/auth/script.external_request https://www.googleapis.com/auth/script.send_mail
因此,我试图将其包含在“输入您的范围框”中。我可以包括其中之一,但只能在框中输入一个范围。如何同时包含两者?
我尝试了以下失败的尝试 https://www.googleapis.com/auth/script.external_request,https://www.googleapis.com/auth/script.send_mail
“ https://www.googleapis.com/auth/script.external_request”,“ https://www.googleapis.com/auth/script.send_mail”
https://www.googleapis.com/auth/script.external_request + https://www.googleapis.com/auth/script.send_mail
解决方法
通常对于Google,范围应以空格分隔:
https://www.googleapis.com/auth/script.external_request https://www.googleapis.com/auth/script.send_mail
Facebook使用逗号,Instagram使用加号...这里列出了一些示例:https://brandur.org/oauth-scope#google
不幸的是,OAuth 2.0规范并未明确定义多作用域,因此OAuth提供者使用了不同的定界符,因此OAuth Playground使用了一个哑文本字段来指定多个范围。
,我解决了以下问题: 一种。我的选择是在以下https://developers.google.com/oauthplayground/
的OAuth操场上添加了客户端ID,机密等c。然后,我编辑了URL以包含我想要的范围,如下所示(以粗体显示):
d。最后,我将该URL粘贴到浏览器中,授权了API,然后继续获取Auth密钥。https://developers.google.com/oauthplayground/#step1&apisSelect= https%3A%2F%2Fmail.google.com%2F%2C https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fscript.send_mail%2C https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fscript.external_request &url = myurl&content_type = application%2Fjson&http_method = POST&useDefaultOauthCred = checked&oauthEndpointSelect = Google&oauthAuthEndpointValue = somevalue&oauthTokenEndpointValue = somevalue&oauthClientId = myClientId&oauthClientSecret = mySecret&accessTokenType = bearer ...