This is a quick demonstration of using Universal Links for OAuth 2.0 redirection. It is NOT suited for any kind of practical application and does not go beyond visiting the authorization endpoint.
Two examples are provided and commented on in the code, and you should be able to try your own Identity Provider and Universal Links setup.
You will need:
-
You will need to associate you project with a development team account and provide the team ID in your Apple App Site Association file, as a part of your app identifier.
-
You will need to add your Universal Links associated domain to the app.
-
Create an OAuth 2.0 client
For example, Google can serve as a provider. For testing Universal Links with Google, you will need an
OAuth client ID
of theWeb application
type. Choosing theiOS
option will let you use a custom scheme only. -
Provide your provider and client details, for example:
// ViewController.swift // . . . authorizationEndpoint = "https://accounts.google.com/o/oauth2/v2/auth" clientId = "your-client.apps.googleusercontent.com" redirectUri = "https://your-associated-domain/your-redirection-path" // . . .