@@ -25,3 +25,210 @@ Follow the [instructions to migrate from Auth0.js v7 to v8](/libraries/auth0js/v
25
25
<%= include('../../_ includes/_ hosted_pages') %>
26
26
<%= include('../../_ includes/_ default_values') %>
27
27
28
+ ## Using Auth0.js to log in users
29
+
30
+ ### Using Auth0.js v7
31
+
32
+ ``` js
33
+ var auth0 = new Auth0 ({
34
+ domain: " your-domain.auth0.com" ,
35
+ clientID: " the-client-id" ,
36
+ responseType: " token"
37
+ });
38
+
39
+ // with the hosted login page
40
+ auth0 .login ({});
41
+
42
+ // with a social connection
43
+ auth0 .login ({
44
+ connection: " twitter"
45
+ });
46
+
47
+ // with username and password
48
+ auth0 .login ({
49
+ connection: " my-db-connection" ,
50
+ username: " the-username" ,
51
+ password: " the-password"
52
+ });
53
+ ```
54
+
55
+ ### Using Auth0.js v9
56
+
57
+ ``` js
58
+ var webAuth = new auth0.WebAuth ({
59
+ domain: " your-domain.auth0.com" ,
60
+ clientID: " the-client-id" ,
61
+ responseType: " token"
62
+ });
63
+
64
+ // with the hosted login page
65
+ webAuth .authorize ({});
66
+
67
+ // with a social connection
68
+ webAuth .authorize ({
69
+ connection: " twitter"
70
+ });
71
+
72
+ // with username and password
73
+ webAuth .login ({
74
+ realm: " my-db-connection" ,
75
+ username: " the-username" ,
76
+
77
+ password: " the-password"
78
+ });
79
+ ```
80
+
81
+ ## Using Auth0.js to log in users without a redirect
82
+
83
+ ### Using Auth0.js v7
84
+
85
+ ``` js
86
+ var auth0 = new Auth0 ({
87
+ domain: " your-domain.auth0.com" ,
88
+ clientID: " the-client-id" ,
89
+ responseType: " token"
90
+ });
91
+
92
+ // with the hosted login page
93
+ auth0 .login ({
94
+ popup: true
95
+ });
96
+
97
+ // with a social connection
98
+ auth0 .login ({
99
+ popup: true ,
100
+ connection: " twitter"
101
+ });
102
+
103
+ // with username and password
104
+ auth0 .login ({
105
+ popup: true ,
106
+ connection: " my-db-connection" ,
107
+ username: " the-username" ,
108
+ password: " the-password"
109
+ });
110
+ ```
111
+
112
+ ### Using Auth0.js v9
113
+
114
+ ``` js
115
+ var webAuth = new auth0.WebAuth ({
116
+ domain: " your-domain.auth0.com" ,
117
+ clientID: " the-client-id" ,
118
+ responseType: " token"
119
+ });
120
+
121
+ // with the hosted login page
122
+ webAuth .popup .authorize ({});
123
+
124
+ // with a social connection
125
+ webAuth .popup .authorize ({
126
+ connection: " twitter"
127
+ });
128
+
129
+ // with username and password
130
+ webAuth .popup .loginWithCredentials ({
131
+ connection: " my-db-connection" ,
132
+ username: " the-username" ,
133
+
134
+ password: " the-password"
135
+ });
136
+ ```
137
+
138
+ ## Using Auth0.js to log in users using Passwordless
139
+
140
+ ### Using Auth0.js v7
141
+
142
+ ``` js
143
+ var auth0 = new Auth0 ({
144
+ domain: " your-domain.auth0.com" ,
145
+ clientID: " the-client-id" ,
146
+ responseType: " token"
147
+ });
148
+
149
+ // with a magic link sent via email
150
+ auth0 .requestMagicLink (
151
+ {
152
+
153
+ },
154
+ function (err ) {}
155
+ );
156
+
157
+ // with a code sent via email
158
+ auth0 .requestEmailCode (
159
+ {
160
+
161
+ },
162
+ function (err ) {}
163
+ );
164
+
165
+ // verifying the email code
166
+ auth0 .verifyEmailCode (
167
+ {
168
+
169
+ code: " the-code"
170
+ },
171
+ function (err , result ) {}
172
+ );
173
+
174
+ // with a code sent via sms
175
+ auth0 .requestSMSCode (
176
+ {
177
+ phoneNumber: " +the_phone_number"
178
+ },
179
+ function (err ) {}
180
+ );
181
+
182
+ // verifying the sms code
183
+ auth0 .verifySMSCode (
184
+ {
185
+ phoneNumber: " +the_phone_number" ,
186
+ code: " the-code"
187
+ },
188
+ function (err , result ) {}
189
+ );
190
+ ```
191
+
192
+ ### Using Auth0.js v9
193
+
194
+ ``` js
195
+ var webAuth = new auth0.WebAuth ({
196
+ domain: " your-domain.auth0.com" ,
197
+ clientID: " the-client-id" ,
198
+ responseType: " token"
199
+ });
200
+
201
+ // with a magic link sent via email
202
+ webAuth .passwordlessStart ({
203
+ send: " link" ,
204
+
205
+ connection: " email"
206
+ });
207
+
208
+ // with a code sent via email
209
+ webAuth .passwordlessStart ({
210
+ send: " code" ,
211
+
212
+ connection: " email"
213
+ });
214
+
215
+ // verifying the email code
216
+ webAuth .passwordlessLogin ({
217
+
218
+ verificationCode: " the-code" ,
219
+ connection: " email"
220
+ });
221
+
222
+ // with a code sent via sms
223
+ webAuth .passwordlessStart ({
224
+ phoneNumber: " +the_phone_number" ,
225
+ connection: " sms"
226
+ });
227
+
228
+ // verifying the sms code
229
+ webAuth .passwordlessLogin ({
230
+ phoneNumber: " +the_phone_number" ,
231
+ verificationCode: " the-code" ,
232
+ connection: " sms"
233
+ });
234
+ ```
0 commit comments