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

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


400. That’s an error.

Error: invalid_request

Storagerelay URI is not allowed for 'NATIVE' client type

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

My Code goes like below:

<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');
    });
}

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

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

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