React-google-login: not able to fire required url

Created on 23 Apr 2017  路  9Comments  路  Source: anthonyjgrove/react-google-login

Most helpful comment

hi @anthonyjgrove

i am facing the same issue. even if i enter a redirect_uri, when using responseType='code', it is not being read and a default redirect_uri with storagerelay://xxxx is being used.

after which, when i use the auth code generated, i will get a redirect_uri_mismatch error, probably because storagerelay://xxxx is not a valid redirect_uri and it cannot be added to the google console.

how can we resolve this?

All 9 comments

Can you please post the version of the component you are using along with including your prop values.

I am using react-google-login version: 2.8.9

                            <ReactGoogleSignIn
                              className='btn btn-primary'
                              offline
                              clientId='CLIENT_ID.apps.googleusercontent.com'
                              scope='https://www.googleapis.com/auth/adsense.readonly'
                              redirectUri='http://localhost:8086/auth2redirect'
                              responseType='code'
                              buttonText='Grant Access'
                              onSuccess={responseGoogle}
                              onFailure={responseGoogle}
                        />

The url fired is
https://accounts.google.com/o/oauth2/auth?redirect_uri=storagerelay%3A%2F%2Fhttp%2Flocalhost%3A8086%3Fid%3Dauth191356&response_type=code+permission+id_token&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fadsense.readonly+openid+profile+email&openid.realm&client_id=13467883700-qp1vrapq1d6767ahigjrc17spfskud4b.apps.googleusercontent.com&ss_domain=http%3A%2F%2Flocalhost%3A8086&access_type=offline&include_granted_scopes=true&origin=http%3A%2F%2Flocalhost%3A8086&gsiwebsdk=2&from_login=1&as=4c5ff16c7294d433&pli=1&authuser=0

Observations:

  1. I am not passing redirectUri, still i see redirect_uri=storagerelay%3A%2F%2Fhttp%2Flocalhost%3A8086%3Fid%3Dauth191356
  2. Passed value for scope is https://www.googleapis.com/auth/adsense.readonly but in the URL scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fadsense.readonly+openid+profile+email
  3. for responceType=code, url has response_type=code+permission+id_token

(I think I might be missing something here or using the wrong props)

I have similar problems as @imtmh has.
<GoogleLogin clientId="CLIENT_ID.apps.googleusercontent.com" buttonText="Login" responseType="code" offline="true" scope="email profile https://www.googleapis.com/auth/youtube" onSuccess={responseGoogle} onFailure={responseGoogle} />
In the url requested https://accounts.google.com/o/oauth2/auth i have following params:

  • redirect_uri:storagerelay://http/localhost:7770?id=auth589157;
  • response_type:code permission id_token (i need only code);
  • scope:email profile https://www.googleapis.com/auth/youtube openid (i don't need openid);
    Are there any updates regarding this problem? I am also using react-google-login version: 2.8.9

@Makiss @imtmh a default redirect_uri seems to get added by Google, I wouldn't worry about it too much unless there's an issue I'm missing.

openid, profile and email scopes also get set as a default, but those can be disabled by explicitly setting fetch_basic_profile to false. This lib currently has a bug when setting fetchBasicProfile={false} but I've submitted a PR describing the issue which hopefully gets merged soon enough :)

Closing due to inactivity.

@anthonyjgrove I am also facing the same issue. How to fire custom redirect_uri?
@imtmh Did u get any solution around this?

hi @anthonyjgrove

i am facing the same issue. even if i enter a redirect_uri, when using responseType='code', it is not being read and a default redirect_uri with storagerelay://xxxx is being used.

after which, when i use the auth code generated, i will get a redirect_uri_mismatch error, probably because storagerelay://xxxx is not a valid redirect_uri and it cannot be added to the google console.

how can we resolve this?

Anyone figure this out or move to another library?

We figured it out. On the server, you must set the redirect_uri="postmessage" . This does break codes from mobile clients, so we needed to make it dynamic by client, but for this library, and our params, this fixes it and we're able successfully validate codes.

OAuth2.Client.new([
      strategy: __MODULE__,
      client_id: ...,
      client_secret: ...,
      redirect_uri: "postmessage",
      site: "https://accounts.google.com",
      authorize_url: "/o/oauth2/auth",
      token_url: "/o/oauth2/token"
    ])

More info here: https://stackoverflow.com/questions/11485271/google-oauth-2-authorization-error-redirect-uri-mismatch

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MiLeung picture MiLeung  路  4Comments

emwee picture emwee  路  4Comments

Praneetha-CK picture Praneetha-CK  路  3Comments

pulkit-max picture pulkit-max  路  8Comments

zoripong picture zoripong  路  7Comments