capacitor-community / generic-oauth2

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

accessTokenEndpoint quirk with django backend #241

Open zhutcho opened 1 year ago

zhutcho commented 1 year ago

Description

I spent a day trying to figure out why I was getting ERR_NO_AUTHORIZATION_CODE on iOS and ERR_AUTHORIZATION_FAILED on Android. It turns out I just needed to add a slash to the end of my accessTokenEndpoint URL e.g.

"https://dummyurl.com/oauth/token" became "https://dummyurl.com/oauth/token/"

Thought I'd post this in case someone else is running into a similar issue, as it's not immediately obvious.

Capacitor version:

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

Library version:

4.0.2

OAuth Provider:

Django

Your Plugin Configuration

const oauth2Options = { appId: "clientID", authorizationBaseUrl: "https://dummyurl.com/oauth/authorize", accessTokenEndpoint: "https://dummyurl.com/oauth/token/", responseType: "code", redirectUrl: "dummyapp://oauth-callback", pkceEnabled: true, };

Affected Platform(s):

moberwasserlechner commented 11 months ago

TODO for myself: Check the urls for trailing / and add it if not exists while building the urls