WithScope ( ) specifies which sets of user data the app is authorized to use if the user logs in successfully. This value is arbitrary for native mobile apps, so we use app to make it clear to other developers and other people who may use the Auth0 settings for this app that the redirect is not to a web page. For web apps, the scheme is http or https. WithScheme ( ) specifies the scheme to use for the URL that Auth0 redirects to after a successful login. Login ( ) initiates the login process and specifies the Auth0 account used by the application. Let’s take a look at what each of the methods in the chain does. The final method in the chain, start ( ), takes the resulting WebAuthProvider object as its argument and uses it to display the login page and define what should happen when the login succeeds and when it fails. From login ( ) to withAudience ( ), each method in the chain takes an argument that provides additional information about the login, using that information to creates a WebAuthProvider object that it passes to the next method in the chain. This is the Builder design pattern in action. If you ignore all the comments and parameters, the method chain looks like this: WebAuthProvider The single line is made of a call to a chain of WebAuthProvider ’s methods starting with login ( ). The WebAuthProvider methods that you’ll use most often are its login ( ) and logout ( ) methods.Īlthough this method is formatted to span several lines, it’s just a single line of code. Login ( ) uses the Auth0 SDK’s WebAuthProvider class, which gives the app the ability to use Auth0’s authentication service. AppCompatActivityĬlass MainActivity : AppCompatActivity ( ) Its contents should look like this: package com. login folder and open the main activity’s file, MainActivity. It’s now time to write the actual code! This is the biggest task in the exercise, so let’s do it in small steps. Write the codeĮverything you’ve done so far in this exercise is just a preamble. In this section, you’ll complete the project and update it to ensure that it works in both portrait and landscape orientations. You set up the project on both the Auth0 and app sides. In the previous section, you started an Android project that uses Auth0 for user login, logout, and reading and updating user metadata.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |