capacitor-community / generic-oauth2

Generic Capacitor OAuth 2 client plugin. Stop the war in Ukraine!
MIT License
230 stars 110 forks source link

IdToken is not available when doing Google OAuth #46

Closed masimplo closed 4 years ago

masimplo commented 5 years ago

I am trying to migrate from cordova-plugin-googleplus. In the previous plugin the response I was getting from logging in with google included an idToken which I sent to my server and obtained a refresh_token and the issuer additionally to all the other info I am getting now if I sent just the access_token that is returned from using this plugin.

Plugins.OAuth2Client.authenticate(
      {
        appId: this._appConfig.thirdPartyAPIs.googleOAuth.clientId,
        authorizationBaseUrl: 'https://accounts.google.com/o/oauth2/auth',
        accessTokenEndpoint: 'https://www.googleapis.com/oauth2/v4/token',
        scope: 'email profile',
        resourceUrl: 'https://www.googleapis.com/userinfo/v2/me',
        web: {
          redirectUrl: 'http://localhost:4200',
          windowOptions: 'height=600,left=0,top=0'
        },
        android: {
          appId: 'xxxx.apps.googleusercontent.com',
          responseType: 'code', // if you configured a android app in google dev console the value must be "code"
          customScheme: 'com.example.android:/'
        },
        ios: {
          appId: 'xxxx.apps.googleusercontent.com',
          responseType: 'code',
          customScheme: 'com.example.app:/'
        }
      }
    )

The response I get contains these fields:

  email: string;
  name: string;
  family_name: string;
  given_name: string;
  verified_email: boolean;
  picture: string;
  locale: string;
  id: string;
  access_token: string;
moberwasserlechner commented 5 years ago

This plugin does not support OpenID, but I created a task to check if it is really just a layer/convention on top of oauth2.

I cannot give you a timeframe until when I will be able to start working on the task, because I have very little sparetime for OSS right now.

See #49

moberwasserlechner commented 4 years ago

Starting with v2.0.0 of the plugin you have access to the id_token, if you provide no resourceUrl. The id_token includes the resource parameters anyway.

kulkarniswapnil commented 4 years ago

If I remove the resourceUrl I am not getting the email, name, and profile related things. Would you please help me to get both id_token and profile info? Thank you.

moberwasserlechner commented 4 years ago

@kulkarniswapnil Please donot comment on closed tasks and create a new task for this. Give as much information as possible.