Using Graph API in an app to read and write from an Excel Workbook

Gabby 0 Reputation points
2023-02-13T18:00:59.6466667+00:00

I'm looking for a way to have my application read and write from an Excel workbook without being logged in. When I use the access token that is generated in Microsoft Graph Explorer, I am able to create a workbook session without being logged in; when I try to generate my own access token using the /ouath2/v2.0/token endpoint and use it to create a workbook session, it returns an error.

Am I using the wrong endpoint to create the token?

Microsoft 365 and Office Development Other
Microsoft 365 and Office Excel For business Windows
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Anonymous
    2023-02-14T12:19:46.73+00:00

    Hi Gabby,

    Thanks for reaching out!

    As per the details provided and based on my understanding, you are trying to generate the access token using OAuth 2.0 authorization code grant type, or auth code flow (Client credential).

    As per the document, currently Create workbook session is not supported for application permissions.

    Reference document: Create Workbook Permissions

    Hope this helps.

    If the reply is helpful, please click "Accept Answer" and kindly upvote it. If you have additional questions about this answer, please click "Comment".


  2. Zehui Yao_MSFT 5,876 Reputation points
    2023-02-15T06:24:47.5166667+00:00

    Hi Gabby, as SaranyaMadhu-MSFT mentioned, create workbook session endpoint does not support application permission and only supports delegated permission.

    At the same time, I would like to add one more point. In Graph explorer, the default token acquisition method is user flow, so the permissions you get are delegated permission. By jwt.ms parsing tokens, you will notice that they are different. So, this may be the cause of the error. Hope it helps you.


    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.


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.