capacitor-community / generic-oauth2

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

Bug: Refresh ignores scope #206

Closed taaem closed 2 years ago

taaem commented 2 years ago

Capacitor version:

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 3.5.1
  @capacitor/core: 3.5.1
  @capacitor/android: 3.5.1
  @capacitor/ios: 3.5.1

Installed Dependencies:

  @capacitor/core: 3.5.0
  @capacitor/cli: 3.5.0
  @capacitor/android: 3.5.0
  @capacitor/ios: 3.5.0

[success] Android looking great! 👌
[error] Xcode is not installed

Library version:

OAuth Provider:

Your Plugin Configuration

{
          refreshToken: refreshToken,
          scope: "email profile offline_access",
          accessTokenEndpoint: OAuthConfig.accessTokenEndpoint,
          appId: OAuthConfig.clientConfiguration.appId,
}

Affected Platform(s):

Current Behavior

If I run Auth2Client.refreshToken({}) with the configuration I posted above, scope gets ignored (eg. I get a normal token and not an offline token). Furthermore I can see in the logs:

native OAuth2Client.refreshToken:
callbackId: "121720501"
methodName: "refreshToken"
options:
accessTokenEndpoint: "endpoint"
appId: "id"
refreshToken: "token"
scope: undefined
__proto__: Object
pluginId: "OAuth2Client"
__proto__: Object

and there I can see that the scope is set to undefined.

Expected Behavior

The scope should be respected during refresh of accessTokens.

Reproduction Steps

  1. Get an accessToken and a refreshToken
  2. Try to refresh the token with a custom scope
taaem commented 2 years ago

Found the issue on my end :smile: