ASWebAuthenticationSession's callbackURLScheme crash

Hi All,

We have started seeing crash with iOS 14.5 for ASWebAuthenticationSession's callbackURLScheme. Is anybody seeing the issue? Is this an intentional change in iOS or a bug?

Code Block
AuthenticationSession] The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".'


Regards,
Nimesh
Answered by Systems Engineer in 676913022

ASWebAuthenticationSession does not require any modification in your Info.plist. This exception happens because the value that was passed to callbackURLScheme contained either a ":" or "/" character. In most cases, this means you passed something like myscheme://, which is not valid.

The correct value to pass in this case is just myscheme (no trailing "://").

Hi, had the same issue.
The solution in my case was to create a new additional scheme only for authentication purpose e.g. "myappauth"
Don't forget to add the scheme to your Info.plist (URL types -> URL Schemes)

Regards,
Vlad
We are experiencing the same issue.
Would be grateful to have a feedback from Apple on this issue.

The solution in my case was to create a new additional scheme only for authentication purpose e.g. "myappauth"

Yes, that is the solution but in all cases its not possible to re-register scheme as we are accessing lot of customer portals.
Would be grateful if someone from Apple address this.

Regards,
Nimesh
Before adding the uri, try url encoding it :
Code Block
callBackURI.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)

This worked for me.
The answer above by apoorvet also worked for me. Wooooo!

Having the same issue now that I build the app with iOS 14.5.

I will use the work-around mentioned by apoorvet (thanks!), but this is surely a bug right?

ASWebAuthenticationSession does not require any modification in your Info.plist. This exception happens because the value that was passed to callbackURLScheme contained either a ":" or "/" character. In most cases, this means you passed something like myscheme://, which is not valid.

The correct value to pass in this case is just myscheme (no trailing "://").

is this issue fixed by Auth0 in latest SDK? I am also facing the same issue with latest xcode.

ASWebAuthenticationSession's callbackURLScheme crash
 
 
Q