@@ -21,7 +21,7 @@ This library _should_ support any OAuth provider that implements the
2121
2222We only support the [ Authorization Code Flow] ( https://oauth.net/2/grant-types/authorization-code/ ) .
2323
24- ### Tested OpenID providers
24+ ## Tested OpenID providers
2525
2626These providers are OpenID compliant, which means you can use [ autodiscovery] ( https://openid.net/specs/openid-connect-discovery-1_0.html ) .
2727
@@ -36,7 +36,7 @@ These providers are OpenID compliant, which means you can use [autodiscovery](ht
3636- [ AWS Cognito] ( https://eu-west-1.console.aws.amazon.com/cognito ) ([ Example configuration] ( ./docs/config-examples/aws-cognito.md ) )
3737- [ Asgardeo] ( https://asgardeo.io ) ([ Example configuration] ( ./docs/config-examples/asgardeo.md ) )
3838
39- ### Tested OAuth2 providers
39+ ## Tested OAuth2 providers
4040
4141These providers implement the OAuth2 spec, but are not OpenID providers, which means you must configure the authorization and token endpoints yourself.
4242
@@ -261,10 +261,15 @@ This is the result from the auth server
261261
262262## Getting started
263263
264+ ``` sh
265+ yarn add react-native-app-auth
266+ ```
267+ Or
264268``` sh
265269npm install react-native-app-auth --save
266270```
267271
272+
268273## Setup
269274
270275### iOS Setup
@@ -275,7 +280,7 @@ To setup the iOS project, you need to perform three steps:
2752802 . [ Register redirect URL scheme] ( #register-redirect-url-scheme )
2762813 . [ Define openURL callback in AppDelegate] ( #define-openurl-callback-in-appdelegate )
277282
278- ##### Install native dependencies
283+ #### Install native dependencies
279284
280285This library depends on the native [ AppAuth-ios] ( https://github.com/openid/AppAuth-iOS ) project. To
281286keep the React Native library agnostic of your dependency management method, the native libraries
@@ -314,7 +319,7 @@ AppAuth supports three options for dependency management.
314319 4. Add ` AppAuth-iOS/Source` to your search paths of your target (" Build Settings -> " Header Search
315320 Paths" ).
316321
317- ##### Register redirect URL scheme
322+ #### Register redirect URL scheme
318323
319324If you intend to support iOS 10 and older, you need to define the supported redirect URL schemes in
320325your ` Info.plist` as follows:
@@ -338,7 +343,7 @@ your `Info.plist` as follows:
338343 beginning of your OAuth Redirect URL, up to the scheme separator (` :` ) character. E.g. if your redirect uri
339344 is ` com.myapp://oauth` , then the url scheme will is ` com.myapp` .
340345
341- ##### Define openURL callback in AppDelegate
346+ #### Define openURL callback in AppDelegate
342347
343348You need to retain the auth session, in order to continue the
344349authorization flow from the redirect. Follow these steps:
@@ -347,6 +352,54 @@ authorization flow from the redirect. Follow these steps:
347352Furthermore, ` RNAppAuth` expects the delegate instance to conform to the protocol ` RNAppAuthAuthorizationFlowManager` .
348353Make ` AppDelegate` conform to ` RNAppAuthAuthorizationFlowManager` with the following changes to ` AppDelegate.h` :
349354
355+ ##### For react-native >= 0.68
356+ Example setup can be see in the [Example app](./Example/ios)
357+
358+ ` ` ` diff
359+ + # import <React/RCTLinkingManager.h>
360+ + #import "RNAppAuthAuthorizationFlowManager.h"
361+
362+ - @interface AppDelegate : RCTAppDelegate
363+ + @interface AppDelegate : RCTAppDelegate <RNAppAuthAuthorizationFlowManager>
364+
365+ + @property(nonatomic, weak) id<RNAppAuthAuthorizationFlowManagerDelegate> authorizationFlowManagerDelegate;
366+ ` ` `
367+
368+ Add the following code to ` AppDelegate.mm` to support React Navigation deep linking and overriding browser behavior in the authorization process
369+
370+ ` ` ` diff
371+ + - (BOOL) application: (UIApplication * )application
372+ + openURL: (NSURL * )url
373+ + options: (NSDictionary< UIApplicationOpenURLOptionsKey, id> * ) options
374+ + {
375+ + if ([self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:url]) {
376+ + return YES;
377+ + }
378+ + return [RCTLinkingManager application:application openURL:url options:options];
379+ + }
380+ ` ` `
381+
382+ If you want to support universal links, add the following to ` AppDelegate.mm` under ` continueUserActivity`
383+
384+ ` ` ` diff
385+ + - (BOOL) application: (UIApplication * ) application
386+ + continueUserActivity: (nonnull NSUserActivity * )userActivity
387+ + restorationHandler: (nonnull void (^)(NSArray< id< UIUserActivityRestoring>> * _Nullable))restorationHandler
388+ + {
389+ + if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
390+ + if (self.authorizationFlowManagerDelegate) {
391+ + BOOL resumableAuth = [self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:userActivity.webpageURL];
392+ + if (resumableAuth) {
393+ + return YES;
394+ + }
395+ + }
396+ + }
397+ + return [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
398+ + }
399+ ` ` `
400+
401+ # #### For react-native < 0.68
402+
350403` ` ` diff
351404+ # import "RNAppAuthAuthorizationFlowManager.h"
352405
0 commit comments