我正在尝试从 Android 客户端使用 Google Calendar API。出于某些原因,我为已安装的应用程序选择了 OAuth 2.0 而不是客户管理器。
https://developers.google.com/accounts/docs/OAuth2InstalledApp
我已经在 Developer API 控制台上注册了我的应用程序,因此我有 client_id 和重定向 uri。控制台不显示 client_secret。
我已经收到来自谷歌服务器的授权码 4/XdlW5dvFW3OWCnKdeG8yDOOjYGAw
https://accounts.google.com/o/oauth2/token?
code=4/XdlW5dvFW3OWCnKdeG8yDOOjYGAw&
client_id=54957922365-fjaa2quhukho8sr5bkpkoq8038vdjh9m.apps.googleusercontent.com&
redirect_uri=urn:ietf:wg:oauth:2.0:oob&
grant_type=authorization_code
如果我使用上述参数制作此 HTTPS URL,我会收到代码中不允许的 405 错误方法。 正如上面 URL 中指定的,我已经添加了参数,但无法使用访问 token 交换授权代码。 有谁知道为什么我在能够检索授权代码时没有获得访问 token ?
最佳答案
感谢代码 fragment ,但我没有在浏览器上发布链接,我已经在 Android 项目中编写了正确的 android HTTPS 代码。仅供引用,我分享了网址。 我已经解决了这个问题。为了帮助其他开发人员,我附上代码: https://github.com/misskhushboo/Code-Snippets.git
关于Android OAuth 2.O 无法检索访问 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14687210/