Forum Discussion

malvinportner's avatar
malvinportner
Copper Contributor
Jan 11, 2023

Get Accesstoken from Connect-MgGraph

Hello there

 

I am using the PowerShell Graph SDK and connecting using the connect-mggraph cmdlet to authenticate to Azure (manual Login).

 

I am assuming, this cmdlet somehow creates something like a temporary app registration and uses this for every further action.

 

Now my question is, if I can somehow get to the access token that the SDK is using on behalf of my User. I then want to make calls to the Graph API with the invoke-restMethod cmdlet

3 Replies



  • In case somebody else has the same question: [System.Text.Encoding]::Ascii.GetString([Microsoft.Graph.PowerShell.Authentication.GraphSession]::Instance.MSALToken) | ConvertFrom-Json

    But you probably don't need it. Usually Invoke-MgGraphRequest suffices.
  • You can use the built-in app, with clientID of 14d82eec-204b-4c2f-b7e8-296a70dab67e. Users will still have to provide credentials though.

Resources