p2 / OAuth2

OAuth2 framework for macOS and iOS, written in Swift.
Other
1.14k stars 276 forks source link

Changes to ASWebAuthenticationSession's callbackURLScheme iOS SDK 14.5 #370

Open ilionsd opened 3 years ago

ilionsd commented 3 years ago

Hello,

Since iOS SDK 14.5 (Xcode 12.5) ASWebAuthenticationSession instantiation might crash with exception:

NSInvalidArgumentException: The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".

The solution would be to use: callBackURI.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) before passing it to callbackURLScheme.

I see that currently URL.scheme is being passed to callbackURLScheme and it should not include ':' or '/', but may be it would be nice to add encoding to future-proof code changes to some extend?

More info here: https://developer.apple.com/forums/thread/679251

Thanks!