0

I am connecting to Microsoft Api. I authenticate using c# and getting the access token, but is cant seem to get the username that authenticated . These are the fields returned token_type, expires_in, access_token, refresh_token, scope

I make a call to MS Graph using the following:

<authUri>?response_type=code&client_id={ClientId}&scope={Scope}&redirect_uri=
<MyRedirectUrl>

Is there a field i can get which can be decoded to get the user name that logged in via the Microsoft screen to authenticate ?

Kristy
  • 39
  • 5
  • Usually you would get that info from the claims in the token itself. – ChiefTwoPencils Sep 27 '22 at 00:53
  • if you decode the `access token`, there normally is a `sub` attribute which stands for `subject`. This is the identified for the user that authenticated. – Andy Refuerzo Sep 27 '22 at 00:53
  • when you mention "decode the token" how can i decode the token ? Is there a standard Microsft routin i can use ? – Kristy Sep 27 '22 at 01:01
  • if you don't want to use a standard MICROSOFT routin to get the username of the signed in user, you can just [decode the access token](https://stackoverflow.com/questions/38340078/how-to-decode-jwt-token) manually. But if you want to use the standard routin, pls show us how you add the authentication so that we may find a suitable solution – Tiny Wang Sep 27 '22 at 01:22
  • @Ting Wang works perfect. – Kristy Sep 27 '22 at 03:55

0 Answers0