1
votes

I have an Excel file added to the drive. I want to get data from it so in the first place I added permission (Files.ReadWrite) according to the documentation to my application on the azure portal.

First, I get an access token from this url: https://login.microsoftonline.com/common/oauth2/v2.0/token

I receive a token, which I then use to complete the GET request from the url: https://graph.microsoft.com/v1.0/me/drive/items/{drive-item-id}/workbook/worksheets/XX/range(address='A4:C4)

I set headers a token according to the documentation of course

'headers' => [
     'Accept' => 'application/json',
     'Authorization' => 'Bearer ' . $this->token
]

And in response I get:

Message: Client error: GET https://graph.microsoft.com/v1.0/me... resulted in a 400 Bad Request response: {"error": {"code": "BadRequest", "message": "Current authenticated context is not valid for this request. (truncated ...) "

How should I do authorize/get token that it to work?

Best regards

1
There isn't a lot of detail here. Please explain how you are obtaining your token.Marc LaFleur
@MarcLaFleur I did a request to "login.microsoftonline.com/common/oauth2/v2.0/token" providing client_id, scope, redirect_uri, client_secret and grant_type. From this I get object where I have access_token or my token, which I still use in the next requestdavid

1 Answers

0
votes

You cannot use /me with Client Credentials (i.e Application scopes) because there is no "me". You need to specify /users/{userId | userPrincipalName}.