Skip to content

Conversation

Dergash
Copy link
Contributor

@Dergash Dergash commented Aug 2, 2021

Description

I was working on migrating existing iOS application to react-native and encountered a problem which took some time for me to debug, so I hope this small readme update can save time for people in similar situation.

The problem was that I had existing redirectUrl specified in uppercase like this:

export const AUTH_CONFIG = {
  // ...
  redirectUrl: `COMPANY://audits`,
}

Following the docs for react-native-app-auth I have to assign appAuthRedirectScheme as a COMPANY part of the redirectUrl:

The scheme is the beginning of your OAuth Redirect URL, up to the scheme separator (:) character. E.g. if your redirect uri
is com.myapp://oauth, then the url scheme will is com.myapp.

But by following this instructions my application failed to catch authorization redirect from sso page to my application.
In fact, although redirectUrl is case-insensitive, appAuthRedirectScheme is not: it is a placeholder variable for <data android:scheme /> element in AppAuth-Android RedirectUriReceiverActivity, and the value of this tag should be lowercased according to official Android guide to app manifest.

android {
    defaultConfig {
        manifestPlaceholders = [
               // 'appAuthRedirectScheme': 'COMPANY' << incorrect
               'appAuthRedirectScheme': 'company' // << correct
        ]
    }

There are existing issues mentioning this problem in other libraries using net.openid:appauth (e.g. openid/AppAuth-Android#533 (comment), MaikuB/flutter_appauth#127 (comment) or stackoverflow), but it's very hard to catch without knowing how appAuthRedirectScheme is used internally.

… for application be able to catch authorization redirect
Copy link
Contributor

@kadikraman kadikraman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this!

@kadikraman kadikraman merged commit a2e0f04 into FormidableLabs:main Aug 15, 2021
@Dergash Dergash deleted the docs/appAuthRedirectScheme-lowercase branch August 15, 2021 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants