Is it mandatory to register an app to use Graph API

Allen Kavalam - External 21 Reputation points

I am having python script that will produce a csv file. I want to upload this to onedrive. When I searched, the first step itself is to create an application in Azure portal. But I can't create application because I don't have access to that feature.
So this is my workaround,
--I am not sure is this the supposed way--
I have gone to Graph explorer. When I run the query I got client request ID and Access token. Using this I will make a curl request like
curl.exe -H "Content-Type:plain/text" -H "Authorization: Bearer access-token-here" -X PUT -H "client-request-id: client-request-id-here" --data-binary "@mutia keyza /to_file.csv"
I am sure if it is working with curl, I can surely make it work using some Python library.
There are two challenges:

  1. Access token will expire soon. so I want to implement refresh token, The example provided in this doc is not suiting my use case
  2. Is giving access token in script a security issue, how can I overcome this.

Thank you

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,052 questions
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 38,936 Reputation points

    First of all, I do not recommend that you directly copy the token in Graph explorer. The token is obtained through your username/password when you log in to the Graph explorer tool. It will expire in a period of time and cannot be refreshed yet, you can only log in to Graph explorer again to get a new token when the token expires.

    And I think that putting the token directly in the script is inherently a certain security problem. So, from the perspective of security and versatility, I suggest you contact your administrator to create an application in the Azure portal, and then use auth code flow in the script to obtain the access token and refresh token.

0 additional answers

Sort by: Most helpful