Closed rajeshpatil74 closed 5 years ago
The token you get from the code is for your web app. You then need to acquire a token for the downstream web api. See https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/wiki/Acquiring-tokens-with-authorization-codes-on-web-apps for details.
jmprieur, I am able to get the token for sharepoint site and its working. There are two additional questions for same -
I need to get two separate tokens for two resources -
By obtaining token, i create multiple sites and perform various operations on these created sites. It takes more than a hour to complete process And meanwhile token gets expired. How i can get token which will expire after 2-3 hrs ? After searching found that i need to create some policy but don't know how to set service principal (get service principal on which policy needs to be set using powershell)
My application registered in AAD is multitenant web application.
@rajeshpatil74
AcquireTokenSilentAsync
with the new resource with the cache for the same user2.Do you use a token cache? (like EFADALTokenCache shown in the sample). Calling AcquireTokenSilentAsync
will refresh the token
Closing as OP has not responded
When the code is received in ProcessCode function and then using the result.AccessToekn gives error "401-unanothroized".
I have given the all access to "O365 SharePoint". The App gets autheticated but using the authorization token received using the code doesn't allow to fetch site details like list, site title etc.