Get Access Token from Azure First Party App without user Interaction

Viewed 63
  • We have a First Party App with Delegated Graph API Permission.
  • We want to get Access Token from this FPA.

As of now we are able to generate token from browser here user need to login in browser to generate token.

Problem: We want to generate token without user interference and want to find a way to get the Token having Delegated Permission on behalf of user also we are using power automate to achieving this functionality.

1 Answers
  • There is a way of getting access tokens and that is by using MSAL

  • Here we would need tenet id , client id , username and password and scope. Tenetidand client id can be aquired from the portal after clicking on your registered app.

enter image description here

  • After that we will also need MSAL which is auth library for azure ad it is available in all language now for example using MSAL for python we can get tokens like this:

client    = # client id from app
tenant    = # tenant id from app
username  = # account username
password  = # account password
scope = [ '2ff814a6-3304-4ab8-85cb-cd0e6f879c1d/.default' ]
app = PublicClientApplication( client_id = client, authority = "https://login.microsoftonline.com/" + tenant ) 
acquire_tokens_result = app.acquire_token_by_username_password( username = username, password = password, scopes = scope )
# acquire_tokens_result['access_token'] this is your tokens

Refer this Ms Documentation on MSAL python

Related