Yur*_*iko 6 google-api drive ios google-drive-api
我正在尝试访问Google Drive API并阅读文档.我的iOS应用首先发出请求,要求获得端点https://accounts.google.com/o/oauth2/v2/auth的许可.
用户授予权限.我得到了一个代码.下一步是授权代码以刷新和访问令牌.
至于安装的应用程序,我不需要发送客户端密码.为了做到这一点,iOS应用程序向端点发送POST请求:
https://www.googleapis.com/oauth2/v4/token
Run Code Online (Sandbox Code Playgroud)
带标题:
Content-Type : application/x-www-form-urlencoded
Run Code Online (Sandbox Code Playgroud)
身体:
code={CODE_FROM_OAUTH_SERVER}&client_id={CLIENT_ID_FROM_CONSOLE}&redirect_uri={APP_BUNDLE_IDENTIFIER}:/code&grant_type=authorization_code
Run Code Online (Sandbox Code Playgroud)
我收到了回复:
{
"error": "unsupported_grant_type",
"error_description": "Invalid grant_type: "
}
Run Code Online (Sandbox Code Playgroud)
应用已在Google控制台中注册.
我的问题是我做错了什么?
它通过POST请求将指定数据发送到 HTTP 服务器,就像我们填写 HTML 表单并提交时浏览器所做的那样。这将导致使用 content-type 将数据传递到服务器application/x-www-form-urlencoded。
您应该尝试更改传递 OAuth 参数的方式,例如client_id、redirect_uri、grant_type、 等。
或者应该尝试使本机客户端成为默认类型。
| 归档时间: |
|
| 查看次数: |
168 次 |
| 最近记录: |