Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google sign-in Storagerelay URI is not allowed for 'NATIVE' client type

I have been trying this simple google sign-in by following this tutorials:

  • https://developers.google.com/identity/sign-in/web/
  • http://www.codexworld.com/login-with-google-account-using-javascript/

The code is very simple and I'm exactly following the same steps as given in these tutorials, but I end up in the below error.


400. That’s an error.

Error: invalid_request

Storagerelay URI is not allowed for 'NATIVE' client type

Storagerelay URI is not allowed for 'NATIVE'

In my credentials I have the configuration like below:

credentials configuration

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

Every time when I click "Sign in with Google" button, new pop-up opens and 400 error throws up.

I also tried growing throw these answers in stackoverflow, but now luck.

  1. Google OAuth 2 authorization - Error: redirect_uri_mismatch
  2. Google Sign-in is not working

My Basic idea is to integrate sign in with google for my web-app, as said in this video, let me know whether this approach is good.

like image 380
yashhy Avatar asked Oct 22 '16 17:10

yashhy


People also ask

How do I redirect a URL in Google console?

Go to your list of load balancers in the Google Cloud console. For a load balancer of type HTTP(S) (Classic), click the load balancer's name link. Click Edit edit. In Host and path rules, select Advanced host and path rule (URL redirect, URL rewrite).

What is Authorized JavaScript origins Google?

An origin is a unique combination of protocol, hostname, and port. In the Authorized JavaScript origins field, enter the origin for your app. You can enter multiple origins to allow for your app to run on different protocols, domains, or subdomains. You cannot use wildcards.

What is Redirect_uri_mismatch?

This error typically means the Client Redirect URL was not properly added to the OAuth Web Application in the Google Cloud Console. To resolve this, the user will need to copy the Client Redirect URL from the Single Sign-On Settings page from ThinkCentral, my.hrw.com, or HMH Ed.


2 Answers

I know this has been answered but in my case, while developing a desktop app with Electron and React, I had set the OAuth2 credential type as "Desktop". Changing it to "Web application" solved it for me.

like image 154
Lucas S. G. Avatar answered Sep 21 '22 01:09

Lucas S. G.


It's because you haven't got your client Id for web server. You did not opt it correctly while doing set up for getting client Id.(You opted it for "Others"). I was facing the exactly same problem but then i changed my client Id for web server and now it's working perfectly.

like image 42
Harshit Singhal Avatar answered Sep 22 '22 01:09

Harshit Singhal