Giter Club home page Giter Club logo

Comments (9)

akiratee avatar akiratee commented on June 3, 2024 5

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?

from react-google-login.

jedashford avatar jedashford commented on June 3, 2024 1

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

from react-google-login.

anthonyjgrove avatar anthonyjgrove commented on June 3, 2024

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

from react-google-login.

imtmh avatar imtmh commented on June 3, 2024

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)

from react-google-login.

Makiss avatar Makiss commented on June 3, 2024

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

from react-google-login.

djankovic avatar djankovic commented on June 3, 2024

@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 :)

from react-google-login.

anthonyjgrove avatar anthonyjgrove commented on June 3, 2024

Closing due to inactivity.

from react-google-login.

Jayiitb avatar Jayiitb commented on June 3, 2024

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

from react-google-login.

jedashford avatar jedashford commented on June 3, 2024

Anyone figure this out or move to another library?

from react-google-login.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.