Get access token from authentication result So, assuming a user has already been authenticated, our request flow will be: You can either store this value after a successful user sign in, or call acquireTokenSilent to make sure the token hasn’t expired.įor readability, our examples in this post will follow the latter approach, but we’d like to note that it’s not required to re-request a token every time you access the API. Once they were authenticated successfully, we then gained access to an IAuthenticationResult object, which contains the accessToken field that we need today!įor each MS Graph API request, you will have to pass in this accessToken value. If you recall, we finished off the MSAL authentication blog post by creating a PublicClientApplication instance and using it to prompt users for their credentials. Once these prerequisites have been satisfied, you can use MSAL to sign in users and acquire access tokens. Registered your app in Azure Portal with permissions for MSAL and MS GraphĬonfigured your Android project to use MSAL More specifically, we’ll cover:īefore we jump into code snippets for calling the MS Graph API, let’s review how to acquire a valid access token from MSAL.Īs a reminder, after following along with previous blog posts, you should have already: In this post, we’ll connect all these ideas together by showing you how to call the MS Graph API in Android apps. Previously, we covered the basics of MSAL and an introduction to MS Graph for Android, so be sure to check out those posts first! This week, we’ll be continuing our blog series on using the Microsoft Authentication Library (MSAL) and the Microsoft Graph to connect to M365 services in your own Android apps.
0 Comments
Leave a Reply. |