【问题标题】:Dont understand Google Drive oAuth 2.0不了解 Google Drive oAuth 2.0
【发布时间】:2017-02-10 11:31:01
【问题描述】:

我需要谷歌驱动器上的 oAuth2。但我无法获得令牌。哪些参数是错误的? Google 文档 API 无法帮助我了解问题所在。 我确实获取请求。

    const options = {
        method: 'post',
        client_id: '{EXAMPLE}deajshot.apps.googleusercontent.com',
        redirect_uri: 'https://drive.google.com/open?id={EXAMPLE}',
        scope: 'https://www.googleapis.com/auth/drive.metadata',
        prompt: 'none',
        mode: 'no-cors',
        response_type: 'token'
    };
    fetch('https://accounts.google.com/o/oauth2/auth',options)
        .then(function (response) {
            console.log(response);
        })

现在我有错误 - 400。这是一个错误。

错误:invalid_request

缺少必需的参数:response_type;

【问题讨论】:

    标签: oauth-2.0 drive


    【解决方案1】:

    通过您的代码示例,您首先需要获取代码,然后请求访问令牌。请尝试按照本教程进行操作:https://developers.google.com/identity/protocols/OpenIDConnect#authenticatingtheuser

    您有一个请求,例如:

    https://accounts.google.com/o/oauth2/v2/auth?
    client_id=424911365001.apps.googleusercontent.com&
    response_type=code&
    scope=openid%20email&
    redirect_uri=https://oauth2-login-demo.example.com/code&
    state=security_token%3D138r5719ru3e1%26url%3Dhttps://oauth2-login-demo.example.com/myHome&
    login_hint=jsmith@example.com&
    openid.realm=example.com&
    hd=example.com
    

    在此之后,使用您的“代码”参数,您可以请求获取访问令牌(您也有此请求的示例)

    祝你好运

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-22
      • 2012-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多