【问题标题】:How to get google auth token from authorization code?如何从授权码中获取谷歌身份验证令牌?
【发布时间】:2016-04-13 12:00:20
【问题描述】:

我尝试如下获取身份验证令牌:

https://accounts.google.com/o/oauth2/token?client_id=xxxxxxxxx&client_secret=xxxxxxxxxxx&grant_type=authorization_code&code=xxxxxxxxxx&redirect_uri=https://bigquery.cloud.google.com/dataset/projectid:datasetid

虽然我已经指定了 grant_type 参数,但我仍然收到以下错误:

 { "error" : "invalid_request", "error_description" : "Required parameter is missing: grant_type" }

我在这里做错了什么?

【问题讨论】:

    标签: authentication oauth-2.0 google-bigquery access-token


    【解决方案1】:

    您需要使用 HTTP POST 并将值放在 POST 参数中,而不是在 HTTP GET 请求中将它们作为查询参数提供。

    【讨论】:

    • 你是如何发送的;哪种工具/环境/语言?
    • 命令行 curl 看起来像:curl -d "client_id=xxxxxxxxx&client_secret=xxxxxxxxxxx&grant_type=authorization_code&code=xxxxxxxxxx&redirect_uri=https://bigquery.cloud.google.com/dataset/projectid:datasetid" https://accounts.google.com/o/oauth2/token;你应该可以用那个来验证
    • 成功了。谢谢。我正在使用邮递员,但它在那里不起作用。
    • 您能告诉我如何获取“code”参数的值吗?我只有 client_id 、 client_secret 和 redirect_uri
    • accounts.google.com/o/oauth2/v2/… 在这个url中填入response_type和client_id,在浏览器中点击url。它将为您提供通过邮件 id 登录的选项。选择,然后您将在浏览器中看到一个 url,其中有 1 个参数作为代码。
    猜你喜欢
    • 1970-01-01
    • 2019-12-07
    • 2021-01-19
    • 2018-09-25
    • 2019-12-29
    • 1970-01-01
    • 1970-01-01
    • 2018-07-01
    • 2022-01-24
    相关资源
    最近更新 更多