Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode 12.5 and iOS 14.5 "Error: The provided scheme is not valid" [with solution] #18

Closed
mjsarfatti opened this issue May 28, 2021 · 4 comments

Comments

@mjsarfatti
Copy link
Contributor

Testing version 3.0.1 of the plugin on iOS 14.5 I get the error:

[AuthenticationSession] Error: The provided scheme is not valid. A scheme must not include any special characters, such as ":" or "/"

which I can track back to OAuthPlugin.swift.

It appears to be the same issue as in auth0/react-native-auth0#360, which is that "Since version 12.5 (released on 26 Apr 2021), Xcode no longer accepts an entire URL for the ASWebAuthenticationSession scheme value."

That issue has a merged PR: auth0/react-native-auth0#369

While I don't know Swift nor C++, I was able to somehow translate that PR and implement a fix that appears to be working.

I say "appears" because due to operating in a strict enterprise development environment I can test only half of the OAuth flow, which is also the reason I'm not sending a PR.

The fix is simply adding two lines (and renaming the corresponding parameter):

    required init(_ endpoint : URL, callbackScheme : String) {
        var url: URL = URL(string: callbackScheme)!                     ⬅️
        var callbackURLScheme: String = url.scheme ?? callbackScheme    ⬅️               ⬇️
        self.aswas = ASWebAuthenticationSession(url: endpoint, callbackURLScheme: callbackURLScheme, completionHandler: { (callBack:URL?, error:Error?) in
            if let incomingUrl = callBack {
                NotificationCenter.default.post(name: NSNotification.Name.CDVPluginHandleOpenURL, object: incomingUrl)
            }
        })
    }

Again, I can't test the whole flow, so if someone could apply that fix and test appropriately would be great!

@flaresys
Copy link

The fix mentioned above worked for me on iOS 14.7.1 devices that were experiencing this issue.

@HarelM
Copy link
Contributor

HarelM commented Mar 20, 2022

I currently see that when trying to use window.open on iOS (I tested it on an iPad) the app crashes.
Was this the behavior that you experienced?
I'll try to take the fix you mention and apply it and see what happens in any case...

@HarelM
Copy link
Contributor

HarelM commented Mar 21, 2022

I've added the relevant fix in PR #23 if anyone is interested, seems to solve the crash that is reported here.

@dpogue
Copy link
Member

dpogue commented Mar 29, 2022

I've released v3.0.2 and v2.0.2 with this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants