Google登录Storagerelay URI不允许用于' NATIVE' 客户类型

yas*_*hhy 10 javascript google-signin googlesigninaccount

按照本教程,我一直在尝试这个简单的谷歌登录:

代码非常简单,我正在按照这些教程中给出的相同步骤进行操作,但最终出现了以下错误.


400. That’s an error.

Error: invalid_request

Storagerelay URI is not allowed for 'NATIVE' client type
Run Code Online (Sandbox Code Playgroud)

'NATIVE'不允许使用Storagerelay URI

在我的凭据中,我有如下配置:

凭证配置

我的代码如下:

<meta name="google-signin-client_id" content="377345478968-2opk94iompa38gja0stu1vi821lr3rt0.apps.googleusercontent.com">
<script src="https://apis.google.com/js/client:platform.js?onload=renderButton" async defer></script>

<div id="gSignIn"></div>


function onSuccess(googleUser) {
    var profile = googleUser.getBasicProfile();
    gapi.client.load('plus', 'v2', function () {
        var request = gapi.client.plus.people.get({
            'userId': 'me'
        });
        //Display the user details
        request.execute(function (resp) {
            console.log(resp);
        });
    });
}
function onFailure(error) {
    alert(error);
}
function renderButton() {
    gapi.signin2.render('gSignIn', {
        'scope': 'profile email',
        'width': 240,
        'height': 50,
        'longtitle': true,
        'theme': 'dark',
        'onsuccess': onSuccess,
        'onfailure': onFailure
    });
}
function signOut() {
    var auth2 = gapi.auth2.getAuthInstance();
    auth2.signOut().then(function () {
        $('.userContent').html('');
        $('#gSignIn').slideDown('slow');
    });
}
Run Code Online (Sandbox Code Playgroud)

每当我点击"使用Google登录"按钮时,系统会弹出新的弹出窗口,并显示400错误.

我也试过在stackoverflow中逐渐抛出这些答案,但现在运气好了.

  1. Google OAuth 2授权 - 错误:redirect_uri_mismatch
  2. Google登录无效

我的基本想法是将登录与google整合到我的网络应用中,如本视频中所述,让我知道这种方法是否合适.

小智 7

这是因为您还没有获得 Web 服务器的客户端 ID。您在设置获取客户端 ID 时没有正确选择它。(您选择了“其他”)。我面临着完全相同的问题,但后来我更改了 Web 服务器的客户端 ID,现在它运行良好。