-
Notifications
You must be signed in to change notification settings - Fork 213
/
Copy pathindex.html
1855 lines (1826 loc) · 95.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html class="default" lang="en" data-base="./">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="IE=edge" />
<title>react-native-auth0</title>
<meta name="description" content="Documentation for react-native-auth0" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="assets/style.css" />
<link rel="stylesheet" href="assets/highlight.css" />
<script defer src="assets/main.js"></script>
<script async src="assets/icons.js" id="tsd-icons-script"></script>
<script async src="assets/search.js" id="tsd-search-script"></script>
<script async src="assets/navigation.js" id="tsd-nav-script"></script>
<script async src="assets/hierarchy.js" id="tsd-hierarchy-script"></script>
</head>
<body>
<script>
document.documentElement.dataset.theme =
localStorage.getItem('tsd-theme') || 'os';
document.body.style.display = 'none';
setTimeout(
() =>
window.app
? app.showPage()
: document.body.style.removeProperty('display'),
500
);
</script>
<header class="tsd-page-toolbar">
<div class="tsd-toolbar-contents container">
<a href="index.html" class="title">react-native-auth0</a>
<div id="tsd-toolbar-links"></div>
<button id="tsd-search-trigger" class="tsd-widget" aria-label="Search">
<svg
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
aria-hidden="true"
>
<use href="assets/icons.svg#icon-search"></use>
</svg>
</button>
<dialog id="tsd-search" aria-label="Search">
<input
role="combobox"
id="tsd-search-input"
aria-controls="tsd-search-results"
aria-autocomplete="list"
aria-expanded="true"
autocapitalize="off"
autocomplete="off"
placeholder="Search the docs"
maxlength="100"
/>
<ul role="listbox" id="tsd-search-results"></ul>
<div id="tsd-search-status" aria-live="polite" aria-atomic="true">
<div>Preparing search index...</div>
</div>
</dialog>
<a
href="#"
class="tsd-widget menu"
id="tsd-toolbar-menu-trigger"
data-toggle="menu"
aria-label="Menu"
><svg
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
aria-hidden="true"
>
<use href="assets/icons.svg#icon-menu"></use></svg
></a>
</div>
</header>
<div class="container container-main">
<div class="col-content">
<div class="tsd-page-title"><h1>react-native-auth0</h1></div>
<div class="tsd-panel tsd-typography">
<p>
<img
src="https://cdn.auth0.com/website/sdks/banners/react-native-auth0-banner.png"
alt="react-native-auth0"
/>
</p>
<p>
<a href="https://circleci.com/gh/auth0/react-native-auth0"
><img
src="https://img.shields.io/circleci/project/github/auth0/react-native-auth0.svg?branch=master&style=flat-square"
alt="Build Status"
/></a>
<a href="https://npmjs.org/package/react-native-auth0"
><img
src="https://img.shields.io/npm/v/react-native-auth0.svg?style=flat-square"
alt="NPM version"
/></a>
<a href="https://codecov.io/github/auth0/react-native-auth0"
><img
src="https://img.shields.io/codecov/c/github/auth0/react-native-auth0.svg?style=flat-square"
alt="Coverage"
/></a>
<a href="#license"
><img
src="https://img.shields.io/npm/l/react-native-auth0.svg?style=flat-square"
alt="License"
/></a>
<a href="https://npmjs.org/package/react-native-auth0"
><img
src="https://img.shields.io/npm/dm/react-native-auth0.svg?style=flat-square"
alt="Downloads"
/></a>
<a
href="https://app.fossa.com/projects/git%2Bgithub.com%2Fauth0%2Freact-native-auth0?ref=badge_shield"
><img
src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fauth0%2Freact-native-auth0.svg?type=shield"
alt="FOSSA Status"
/></a>
</p>
<p>
📚 <a href="#documentation">Documentation</a> • 🚀
<a href="#getting-started">Getting Started</a> • ⏭️
<a href="#next-steps">Next Steps</a> • ❓
<a
href="https://github.com/auth0/react-native-auth0/blob/master/FAQ.md"
>FAQs</a
>
• ❓ <a href="#feedback">Feedback</a>
</p>
<h3 id="⚠️-important-migration-notice-v400" class="tsd-anchor-link">
⚠️ Important Migration Notice: v4.0.0<a
href="#⚠️-important-migration-notice-v400"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h3>
<p>
We're excited to announce the release of react-native-auth0
<code>v4.0.0</code>! Please note that this update includes breaking
changes that require your attention. To ensure a smooth transition,
please review our 👉
<a
href="https://github.com/auth0/react-native-auth0/blob/master/MIGRATION_GUIDE.md"
>Migration Guide</a
>
👈 for detailed instructions on updating your integration.
</p>
<h2 id="documentation" class="tsd-anchor-link">
Documentation<a
href="#documentation"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h2>
<ul>
<li>
<a
href="https://auth0.com/docs/quickstart/native/react-native/interactive"
>Quickstart</a
>
</li>
<li>
<a
href="https://auth0.com/docs/quickstart/native/react-native-expo/interactive"
>Expo Quickstart</a
>
</li>
<li>
<a
href="https://github.com/auth0-samples/auth0-react-native-sample/tree/master/00-Login-Hooks"
>Sample App</a
>
</li>
<li>
<a
href="https://github.com/auth0-samples/auth0-react-native-sample/tree/master/00-Login-Expo"
>Expo Sample App</a
>
</li>
<li>
<a
href="https://github.com/auth0/react-native-auth0/blob/master/FAQ.md"
>FAQs</a
>
</li>
<li>
<a
href="https://github.com/auth0/react-native-auth0/blob/master/EXAMPLES.md"
>Examples</a
>
</li>
<li>
<a href="https://auth0.github.io/react-native-auth0/"
>Docs Site</a
>
</li>
</ul>
<h2 id="getting-started" class="tsd-anchor-link">
Getting Started<a
href="#getting-started"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h2>
<h3 id="requirements" class="tsd-anchor-link">
Requirements<a
href="#requirements"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h3>
<p>
This SDK targets apps that are using React Native SDK version
<code>0.65.0</code> and up. If you're using an older React Native
version, see the compatibility matrix below.
</p>
<h3 id="platform-compatibility" class="tsd-anchor-link">
Platform compatibility<a
href="#platform-compatibility"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h3>
<p>
The following shows platform minimums for running projects with this
SDK:
</p>
<table>
<thead>
<tr>
<th>Platform</th>
<th style="text-align: center">Minimum version</th>
</tr>
</thead>
<tbody>
<tr>
<td>iOS</td>
<td style="text-align: center">13.0</td>
</tr>
<tr>
<td>Android</td>
<td style="text-align: center">34</td>
</tr>
</tbody>
</table>
<p>
Our SDK requires a minimum iOS deployment target of 13.0. In your
project's ios/Podfile, ensure your platform target is set to 13.0.
</p>
<pre><code><span class="hl-0">platform</span><span class="hl-1"> :</span><span class="hl-2">ios</span><span class="hl-1">, </span><span class="hl-3">'13.0'</span>
</code><button>Copy</button></pre>
<h3 id="installation" class="tsd-anchor-link">
Installation<a
href="#installation"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h3>
<p>First install the native library module:</p>
<h3 id="with-npm" class="tsd-anchor-link">
With <a href="https://www.npmjs.com">npm</a
><a href="#with-npm" aria-label="Permalink" class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h3>
<p><code>$ npm install react-native-auth0 --save</code></p>
<h3 id="with-yarn" class="tsd-anchor-link">
With <a href="https://yarnpkg.com/en/">Yarn</a
><a href="#with-yarn" aria-label="Permalink" class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h3>
<p><code>$ yarn add react-native-auth0</code></p>
<p>
Then, you need to run the following command to install the ios app
pods with Cocoapods. That will auto-link the iOS library:
</p>
<p><code>$ cd ios && pod install</code></p>
<h3 id="configure-the-sdk" class="tsd-anchor-link">
Configure the SDK<a
href="#configure-the-sdk"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h3>
<p>
You need to make your Android, iOS or Expo applications aware that
an authentication result will be received from the browser. This SDK
makes use of the Android's Package Name and its analogous iOS's
Product Bundle Identifier to generate the redirect URL. Each
platform has its own set of instructions.
</p>
<h4 id="android" class="tsd-anchor-link">
Android<a
href="#android"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h4>
<p>
> Before version 2.9.0, this SDK required you to add an intent
filter to the Activity on which you're going to receive the
authentication result, and to use the <code>singleTask</code>
<strong>launchMode</strong> in that activity. To migrate your app to
version 2.9.0+, <strong>remove both</strong> and continue with the
instructions below. > You can also check out a sample migration
diff
<a
href="https://github.com/auth0-samples/auth0-react-native-sample/commit/69f79c83ceed40f44b239bbd16e79ecaa70ef70a"
>here</a
>.
</p>
<p>
Open your app's <code>build.gradle</code> file (typically at
<code>android/app/build.gradle</code>) and add the following
manifest placeholders:
</p>
<pre><code class="groovy">android {
defaultConfig {
// Add the next line
manifestPlaceholders = [auth0Domain: "YOUR_AUTH0_DOMAIN", auth0Scheme: "${applicationId}.auth0"]
}
...
}
</code><button type="button">Copy</button></pre>
<p>
The <code>auth0Domain</code> value must be replaced with your Auth0
domain value. So if you have <code>samples.us.auth0.com</code> as
your Auth0 domain you would have a configuration like the following:
</p>
<pre><code class="groovy">android {
defaultConfig {
manifestPlaceholders = [auth0Domain: "samples.us.auth0.com", auth0Scheme: "${applicationId}.auth0"]
}
...
}
</code><button type="button">Copy</button></pre>
<p>
The <code>applicationId</code> value will be auto-replaced at
runtime with the package name or ID of your application (e.g.
<code>com.example.app</code>). You can change this value from the
<code>build.gradle</code> file. You can also check it at the top of
your <code>AndroidManifest.xml</code> file.
</p>
<p>
> Note that if your Android application is using
<a
href="https://developer.android.com/studio/build/build-variants#product-flavors"
>product flavors</a
>, you might need to specify different manifest placeholders for
each flavor.
</p>
<p>
If you use a value other than <code>applicationId</code> in
<code>auth0Scheme</code> you will also need to pass it as the
<code>customScheme</code> option parameter of the
<code>authorize</code> and <code>clearSession</code> methods.
</p>
<p>
Take note of this value as you'll be requiring it to define the
callback URLs below.
</p>
<p>
> For more info please read the
<a href="https://facebook.github.io/react-native/docs/linking.html"
>React Native docs</a
>.
</p>
<h5
id="skipping-the-web-authentication-setup"
class="tsd-anchor-link"
>
Skipping the Web Authentication setup<a
href="#skipping-the-web-authentication-setup"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h5>
<p>
If you don't plan to use Web Authentication, you will notice that
the compiler will still prompt you to provide the
<code>manifestPlaceholders</code> values, since the
<code>RedirectActivity</code> included in this library will require
them, and the Gradle tasks won't be able to run without them.
</p>
<p>
Re-declare the activity manually with
<code>tools:node="remove"</code> in your app's Android
Manifest in order to make the manifest merger remove it from the
final manifest file. Additionally, one more unused activity can be
removed from the final APK by using the same process. A complete
snippet to achieve this is:
</p>
<pre><code class="xml"><activity
android:name="com.auth0.android.provider.AuthenticationActivity"
tools:node="remove"/>
<!-- Optional: Remove RedirectActivity -->
<activity
android:name="com.auth0.android.provider.RedirectActivity"
tools:node="remove"/>
</code><button type="button">Copy</button></pre>
<h4 id="ios" class="tsd-anchor-link">
iOS<a href="#ios" aria-label="Permalink" class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h4>
<p>
Inside the <code>ios</code> folder find the file
<code>AppDelegate.[swift|m]</code> add the following to it:
</p>
<pre><code class="objc">#import <React/RCTLinkingManager.h>
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
{
return [RCTLinkingManager application:app openURL:url options:options];
}
</code><button type="button">Copy</button></pre>
<p>
Inside the <code>ios</code> folder open the
<code>Info.plist</code> and locate the value for
<code>CFBundleIdentifier</code>, e.g.
</p>
<pre><code class="xml"><key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
</code><button type="button">Copy</button></pre>
<p>
and then below it register a URL type entry using the value of
<code>CFBundleIdentifier</code> as the value for
<code>CFBundleURLSchemes</code>:
</p>
<pre><code class="xml"><key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>None</string>
<key>CFBundleURLName</key>
<string>auth0</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).auth0</string>
</array>
</dict>
</array>
</code><button type="button">Copy</button></pre>
<p>
If your application is generated using the React Native CLI, the
default value of <code>$(PRODUCT_BUNDLE_IDENTIFIER)</code> matches
<code
>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</code
>. Take note of this value as you'll be requiring it to define the
callback URLs below. If desired, you can change its value using
XCode in the following way:
</p>
<ul>
<li>
Open the <code>ios/TestApp.xcodeproj</code> file replacing
'TestApp' with the name of your app or run
<code>xed ios</code> from a Terminal.
</li>
<li>
Open your project's or desired target's
<strong>Build Settings</strong> tab and on the search bar at the
right type "Product Bundle Identifier".
</li>
<li>
Replace the <strong>Product Bundle Identifier</strong> value with
your desired application's bundle identifier name (e.g.
<code>com.example.app</code>).
</li>
<li>
If you've changed the project wide settings, make sure the same
were applied to each of the targets your app has.
</li>
</ul>
<p>
If you use a value other than
<code>$(PRODUCT_BUNDLE_IDENTIFIER)</code> in the
<code>CFBundleURLSchemes</code> field of the
<code>Info.plist</code> you will also need to pass it as the
<code>customScheme</code> option parameter of the
<code>authorize</code> and <code>clearSession</code> methods.
</p>
<p>
> For more info please read the
<a href="https://facebook.github.io/react-native/docs/linking.html"
>React Native docs</a
>.
</p>
<h4 id="expo" class="tsd-anchor-link">
Expo<a href="#expo" aria-label="Permalink" class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h4>
<p>
> :warning: This SDK is not compatible with "Expo Go"
app because of custom native code. It is compatible with Custom Dev
Client and EAS builds
</p>
<p>
To use the SDK with Expo, configure the app at build time by
providing the <code>domain</code> and the
<code>customScheme</code> values through the
<a href="https://docs.expo.dev/guides/config-plugins/"
>Config Plugin</a
>. To do this, add the following snippet to <em>app.json</em> or
<em>app.config.js</em>:
</p>
<pre><code class="json"><span class="hl-1">{</span><br/><span class="hl-1"> </span><span class="hl-4">"expo"</span><span class="hl-1">: {</span><br/><span class="hl-1"> </span><span class="hl-5">...</span><br/><span class="hl-1"> </span><span class="hl-4">"plugins"</span><span class="hl-1">: [</span><br/><span class="hl-1"> [</span><br/><span class="hl-1"> </span><span class="hl-3">"react-native-auth0"</span><span class="hl-1">,</span><br/><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-4">"domain"</span><span class="hl-1">: </span><span class="hl-3">"YOUR_AUTH0_DOMAIN"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-4">"customScheme"</span><span class="hl-1">: </span><span class="hl-3">"YOUR_CUSTOM_SCHEME"</span><br/><span class="hl-1"> }</span><br/><span class="hl-1"> ]</span><br/><span class="hl-1"> ]</span><br/><span class="hl-1"> }</span><br/><span class="hl-1">}</span>
</code><button type="button">Copy</button></pre>
<p>
> :info: If you want to switch between multiple domains in your
app, refer
<a
href="https://github.com/auth0/react-native-auth0/blob/master/EXAMPLES.md#domain-switching"
>here</a
>
</p>
<table>
<thead>
<tr>
<th>API</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>domain</td>
<td>
Mandatory: Provide the Auth0 domain that can be found at the
<a href="https://manage.auth0.com/#/applications"
>Application Settings</a
>
</td>
</tr>
<tr>
<td>customScheme</td>
<td>
Optional: Custom scheme to build the callback URL with. The
value provided here should be passed to the
<code>customScheme</code> option parameter of the
<code>authorize</code> and <code>clearSession</code> methods.
The custom scheme should be a unique, all lowercase value with
no special characters.
</td>
</tr>
</tbody>
</table>
<p>
Now you can run the application using
<code>expo run:android</code> or <code>expo run:ios</code>.
</p>
<h3 id="callback-urls" class="tsd-anchor-link">
Callback URL(s)<a
href="#callback-urls"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h3>
<p>
Callback URLs are the URLs that Auth0 invokes after the
authentication process. Auth0 routes your application back to this
URL and appends additional parameters to it, including a token.
Since callback URLs can be manipulated, you will need to add this
URL to your Application's <strong>Allowed Callback URLs</strong> for
security. This will enable Auth0 to recognize these URLs as valid.
If omitted, authentication will not be successful.
</p>
<p>
On the Android platform this URL is case-sensitive. Because of that,
this SDK will auto convert the Bundle Identifier (iOS) and
Application ID (Android) values to lowercase in order to build the
Callback URL with them. If any of these values contains uppercase
characters a warning message will be printed in the console. Make
sure to check that the right Callback URL is whitelisted in the
Auth0 dashboard or the browser will not route successfully back to
your application.
</p>
<p>
Go to the
<a href="https://manage.auth0.com/#/applications">Auth0 Dashboard</a
>, select your application and make sure that
<strong>Allowed Callback URLs</strong> contains the URLs defined
below.
</p>
<p>
If in addition you plan to use the log out method, you must also add
these URLs to the <strong>Allowed Logout URLs</strong>.
</p>
<p>
> [!NOTE] > Whenever possible, Auth0 recommends using
<a href="https://developer.android.com/training/app-links"
>Android App Links</a
>
and
<a
href="https://developer.apple.com/documentation/xcode/allowing-apps-and-websites-to-link-to-your-content"
>Apple Universal Links</a
>
for your callback and logout URLs. Custom URL schemes can be subject
to
<a href="https://datatracker.ietf.org/doc/html/rfc8252#section-8.6"
>client impersonation attacks</a
>. > > 💡 If your Android app is using
<a
href="https://developer.android.com/studio/build/build-variants#product-flavors"
>product flavors</a
>, you might need to specify different manifest placeholders for
each flavor.
</p>
<h4 id="android-1" class="tsd-anchor-link">
Android<a
href="#android-1"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h4>
<h5 id="custom-scheme" class="tsd-anchor-link">
Custom Scheme<a
href="#custom-scheme"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h5>
<pre><code class="text">{YOUR_APP_PACKAGE_NAME}.auth0://{YOUR_AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback
</code><button type="button">Copy</button></pre>
<h5 id="app-link-recommended" class="tsd-anchor-link">
App Link (Recommended):<a
href="#app-link-recommended"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h5>
<pre><code class="text">https://{YOUR_AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback
</code><button type="button">Copy</button></pre>
<p>
> Replace {YOUR_APP_PACKAGE_NAME} and {YOUR_AUTH0_DOMAIN} with
your actual application package name and Auth0 domain. Ensure that
{YOUR_APP_PACKAGE_NAME} is all lowercase.
</p>
<p>
To enable App Links, set the <code>auth0Scheme</code> to
<code>https</code> in your <code>build.gradle</code> file.
</p>
<pre><code class="text">android {
defaultConfig {
manifestPlaceholders = [auth0Domain: "@string/com_auth0_domain", auth0Scheme: "https"]
}
}
</code><button type="button">Copy</button></pre>
<p>
This configuration ensures that your app uses https for the callback
URL scheme, which is required for Android App Links.
</p>
<h4 id="enable-android-app-links-support" class="tsd-anchor-link">
Enable Android App Links Support<a
href="#enable-android-app-links-support"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h4>
<p>
<a href="https://developer.android.com/training/app-links"
>Android App Links</a
>
allow an application to designate itself as the default handler of a
given type of link. For example, clicking a URL in an email would
open the link in the designated application. This guide will show
you how to enable Android App links support for your
Auth0-registered application using Auth0's Dashboard.
</p>
<ol>
<li>
<p>
Go to
<a href="https://manage.auth0.com/#/applications"
>Auth0 Dashboard > Applications > Applications</a
>, and select the name of the application to view.
</p>
</li>
<li>
<p>
Scroll to the bottom of the Settings page, and select
<strong>Show Advanced Settings</strong>.
</p>
</li>
<li>
<p>
Select Device Settings, provide the
<a
href="https://developer.android.com/studio/build/application-id"
>App Package Name and</a
>
the SHA256 fingerprints of your app’s signing certificate for
your Android application, and select Save Changes.
<img src="media/android-app-link.png" alt="android-app-link" />
</p>
</li>
</ol>
<p>
> You can use the following command to generate the fingerprint
using the Java keytool in your terminal:
<code>keytool -list -v -keystore my-release-key.keystore</code>
</p>
<p>
To learn more about signing certificates, see Android's
<a
href="https://developer.android.com/studio/publish/app-signing.html"
>Sign Your App</a
>
developer documentation.
</p>
<h4 id="ios-1" class="tsd-anchor-link">
iOS<a href="#ios-1" aria-label="Permalink" class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h4>
<h5 id="custom-scheme-1" class="tsd-anchor-link">
Custom Scheme<a
href="#custom-scheme-1"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h5>
<pre><code class="text">{PRODUCT_BUNDLE_IDENTIFIER}.auth0://{YOUR_AUTH0_DOMAIN}/ios/{PRODUCT_BUNDLE_IDENTIFIER}/callback
</code><button type="button">Copy</button></pre>
<h5 id="universal-link-recommended" class="tsd-anchor-link">
Universal Link (Recommended):<a
href="#universal-link-recommended"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h5>
<pre><code class="text">https://{YOUR_AUTH0_DOMAIN}/ios/{PRODUCT_BUNDLE_IDENTIFIER}/callback
</code><button type="button">Copy</button></pre>
<p>
> Replace <code>{PRODUCT_BUNDLE_IDENTIFIER}</code> and
<code>{YOUR_AUTH0_DOMAIN}</code> with your actual product bundle
identifier and Auth0 domain. Ensure that {PRODUCT_BUNDLE_IDENTIFIER}
is all lowercase.
</p>
<h4
id="configure-an-associated-domain-for-ios"
class="tsd-anchor-link"
>
Configure an associated domain for iOS<a
href="#configure-an-associated-domain-for-ios"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h4>
<p>
> [!IMPORTANT] > This step requires a paid Apple Developer
account. It is needed to use Universal Links as callback and logout
URLs. > Skip this step to use a custom URL scheme instead.
</p>
<h5
id="configure-the-team-id-and-bundle-identifier"
class="tsd-anchor-link"
>
Configure the Team ID and bundle identifier<a
href="#configure-the-team-id-and-bundle-identifier"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h5>
<p>
Scroll to the end of the settings page of your Auth0 application and
open <strong>Advanced Settings > Device Settings</strong>. In the
<strong>iOS</strong> section, set <strong>Team ID</strong> to your
<a
href="https://developer.apple.com/help/account/manage-your-team/locate-your-team-id/"
>Apple Team ID</a
>, and <strong>App ID</strong> to your app's bundle identifier.
</p>
<p>
<img
src="https://github.com/auth0/Auth0.swift/assets/5055789/7eb5f6a2-7cc7-4c70-acf3-633fd72dc506"
alt="Screenshot of the iOS section inside the Auth0 application settings page"
/>
</p>
<p>
This will add your app to your Auth0 tenant's
<code>apple-app-site-association</code> file.
</p>
<h5 id="add-the-associated-domain-capability" class="tsd-anchor-link">
Add the associated domain capability<a
href="#add-the-associated-domain-capability"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h5>
<p>
In Xcode, go to the <strong>Signing and Capabilities</strong>
<a
href="https://developer.apple.com/documentation/xcode/adding-capabilities-to-your-app#Add-a-capability"
>tab</a
>
of your app's target settings, and press the
<strong>+ Capability</strong> button. Then select
<strong>Associated Domains</strong>.
</p>
<p>
<img
src="https://github.com/auth0/Auth0.swift/assets/5055789/3f7b0a70-c36c-46bf-9441-29f98724204a"
alt="Screenshot of the capabilities library inside Xcode"
/>
</p>
<p>
Next, add the following
<a
href="https://developer.apple.com/documentation/xcode/configuring-an-associated-domain#Define-a-service-and-its-associated-domain"
>entry</a
>
under <strong>Associated Domains</strong>:
</p>
<pre><code class="text">webcredentials:YOUR_AUTH0_DOMAIN
</code><button type="button">Copy</button></pre>
<p><details> <summary>Example</summary></p>
<p>
If your Auth0 Domain were <code>example.us.auth0.com</code>, then
this value would be:
</p>
<pre><code class="text">webcredentials:example.us.auth0.com
</code><button type="button">Copy</button></pre>
<p></details></p>
<p>
If you have a <a
href="https://auth0.com/docs/customize/custom-domains"
>custom domain</a
>, replace <code>YOUR_AUTH0_DOMAIN</code> with your custom domain.
</p>
<p>
> [!NOTE] > For the associated domain to work, your app must
be signed with your team certificate
<strong>even when building for the iOS simulator</strong>. Make sure
you are using the Apple Team whose Team ID is configured in the
settings page of your Auth0 application.
</p>
<p>
Refer to the example of
<a
href="https://github.com/auth0/react-native-auth0/blob/master/EXAMPLES.md#using-custom-scheme-for-web-authentication-redirection"
>Using custom scheme for web authentication redirection</a
>
</p>
<h2 id="next-steps" class="tsd-anchor-link">
Next Steps<a
href="#next-steps"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h2>
<p>
> This SDK is OIDC compliant. To ensure OIDC compliant responses
from the Auth0 servers enable the
<strong>OIDC Conformant</strong> switch in your Auth0 dashboard
under <code>Application / Settings / Advanced OAuth</code>. For more
information please check
<a
href="https://auth0.com/docs/api-auth/intro#how-to-use-the-new-flows"
>this documentation</a
>.
</p>
<h3 id="web-authentication" class="tsd-anchor-link">
Web Authentication<a
href="#web-authentication"
aria-label="Permalink"
class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h3>
<p>
The SDK exports a React hook as the primary interface for performing
<a href="#web-authentication">web authentication</a> through the
browser using Auth0
<a
href="https://auth0.com/docs/authenticate/login/auth0-universal-login"
>Universal Login</a
>.
</p>
<p>
Use the methods from the <code>useAuth0</code> hook to implement
login, logout, and to retrieve details about the authenticated user.
</p>
<p>
See the
<a
href="https://auth0.github.io/react-native-auth0/functions/useAuth0.html"
>API Documentation</a
>
for full details on the <code>useAuth0</code> hook.
</p>
<p>
First, import the <code>Auth0Provider</code> component and wrap it
around your application. Provide the <code>domain</code> and
<code>clientId</code> values as given to you when setting up your
Auth0 app in the dashboard:
</p>
<pre><code class="js"><span class="hl-6">import</span><span class="hl-1"> { </span><span class="hl-2">Auth0Provider</span><span class="hl-1"> } </span><span class="hl-6">from</span><span class="hl-1"> </span><span class="hl-3">'react-native-auth0'</span><span class="hl-1">;</span><br/><br/><span class="hl-7">const</span><span class="hl-1"> </span><span class="hl-8">App</span><span class="hl-1"> = () =&</span><span class="hl-2">gt</span><span class="hl-1">; {</span><br/><span class="hl-1"> </span><span class="hl-6">return</span><span class="hl-1"> (</span><br/><span class="hl-1"> &</span><span class="hl-2">lt</span><span class="hl-1">;</span><span class="hl-2">Auth0Provider</span><span class="hl-1"> </span><span class="hl-2">domain</span><span class="hl-1">=</span><span class="hl-3">"YOUR_AUTH0_DOMAIN"</span><span class="hl-1"> </span><span class="hl-2">clientId</span><span class="hl-1">=</span><span class="hl-3">"YOUR_AUTH0_CLIENT_ID"</span><span class="hl-1">&</span><span class="hl-2">gt</span><span class="hl-1">;</span><br/><span class="hl-1"> {</span><span class="hl-9">/* YOUR APP */</span><span class="hl-1">}</span><br/><span class="hl-1"> &</span><span class="hl-2">lt</span><span class="hl-1">;/</span><span class="hl-2">Auth0Provider</span><span class="hl-1">&</span><span class="hl-2">gt</span><span class="hl-1">;</span><br/><span class="hl-1"> );</span><br/><span class="hl-1">};</span><br/><br/><span class="hl-6">export</span><span class="hl-1"> </span><span class="hl-6">default</span><span class="hl-1"> </span><span class="hl-2">App</span><span class="hl-1">;</span>
</code><button type="button">Copy</button></pre>
<p>
<details> <summary>Using the
<code>Auth0</code> class</summary>
</p>
<p>
If you're not using React Hooks, you can simply instantiate the
<code>Auth0</code> class:
</p>
<pre><code class="js"><span class="hl-6">import</span><span class="hl-1"> </span><span class="hl-2">Auth0</span><span class="hl-1"> </span><span class="hl-6">from</span><span class="hl-1"> </span><span class="hl-3">'react-native-auth0'</span><span class="hl-1">;</span><br/><br/><span class="hl-7">const</span><span class="hl-1"> </span><span class="hl-8">auth0</span><span class="hl-1"> = </span><span class="hl-7">new</span><span class="hl-1"> </span><span class="hl-10">Auth0</span><span class="hl-1">({</span><br/><span class="hl-1"> </span><span class="hl-2">domain:</span><span class="hl-1"> </span><span class="hl-3">'YOUR_AUTH0_DOMAIN'</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-2">clientId:</span><span class="hl-1"> </span><span class="hl-3">'YOUR_AUTH0_CLIENT_ID'</span><span class="hl-1">,</span><br/><span class="hl-1">});</span>
</code><button type="button">Copy</button></pre>
<p></details></p>
<p>
Then import the hook into a component where you want to get access
to the properties and methods for integrating with Auth0:
</p>
<pre><code class="js"><span class="hl-6">import</span><span class="hl-1"> { </span><span class="hl-2">useAuth0</span><span class="hl-1"> } </span><span class="hl-6">from</span><span class="hl-1"> </span><span class="hl-3">'react-native-auth0'</span><span class="hl-1">;</span>
</code><button type="button">Copy</button></pre>
<h4 id="login" class="tsd-anchor-link">
Login<a href="#login" aria-label="Permalink" class="tsd-anchor-icon"
><svg viewBox="0 0 24 24" aria-hidden="true">
<use href="assets/icons.svg#icon-anchor"></use></svg
></a>
</h4>
<p>
Use the <code>authorize</code> method to redirect the user to the
Auth0
<a
href="https://auth0.com/docs/authenticate/login/auth0-universal-login"
>Universal Login</a
>
page for authentication. If <code>scope</code> is not specified,
<code>openid profile email</code> is used by default.
</p>