Why am i getting an invalid access token from On-behalf-of-flow

Yatin Tripathi 20 Reputation points
2023-05-18T12:17:58.9966667+00:00

When I am using On-Behalf -Of-Flow and hitting /token endpoint with "common" tenant and word as middletier token as assertion with scopes as "openid profile offline_access user.read" i get a malinformed token , but it works for /me endpoint of microsoft graph, but not works for other microsoft api's such as GetAllFolders api etc.

{
  token_type: 'Bearer',
  scope: 'User.Read openid profile',
  expires_in: 2148,
  ext_expires_in: 2148,
  access_token: 'EwBoA8l6BAAUAOyDv0l6PcCVu89kmzvqZmkWABkAAcC8ou4ZlNy/KWYLLdVH0vH5mX0MiAuWOx+gxF.............................................................................................................................................................................................................................................9bsbChhpSgTqaDAn2/5e2ol0e+jVUfSFYGNfr45kqBZUoB32Q2HFI1p8wpIdQPOMXfQI=',
  refresh_token: 'M.C105_BAY.-CW5CZWj8ujA1gjI*WNj2u.........................................................................................................................................Ld5Mv40fbrVowHZdbrDkTPFTaKFidgiAN!qZhx472zJNxxnW0iVOFfQqNtU$',
  id_token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJS.........................................................................................................................................................................................................................83ZPxcotsRG-wGV30ULbnXyI8PFg'
}

Normally a accessToken starts with "ey..." , when we add more scopes we get different responses such as :-

{
  error: 'invalid_grant',
  error_description: "AADSTS500202: User account '{EmailHidden}' from external identity provider 'live.com' is not supported for API version '2.0'. Microsoft account pass-thru users and guests are not supported by the tenant-independent endpoint.\r\n" +
    'Trace ID: 5cc0f975-7e48-4a20-87b1-12dbec691300\r\n' +
    'Correlation ID: 027cda66-c8cf-41a8-9aa6-328244611c8a\r\n' +
    'Timestamp: 2023-05-18 12:14:01Z',
  error_codes: [ 500202 ],
  timestamp: '2023-05-18 12:14:01Z',
  trace_id: '5cc0f975-7e48-4a20-87b1-12dbec691300',
  correlation_id: '027cda66-c8cf-41a8-9aa6-328244611c8a'
}
Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. Zehui Yao_MSFT 5,876 Reputation points
    2023-05-19T02:29:58.5966667+00:00

    Hi Yatin Tripathi ,access Token that start with "Ew..." mean that the user you're logged in with is a personal Microsoft account, since common allows Microsoft accounts and work or school accounts to sign in. Hope this helps Best Wishes.

    User's image

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.