Microsoft Graph API Authorization Code

Ken Exton 6 Reputation points
2022-12-31T16:20:47.997+00:00

So I am trying to set up Microsoft Graph API to make Teams calls. I work in a government tenant, GCC High environment. I have successfully been able to get the authorization code, use it to get the access token and create and get a meeting. My question is how do I go about getting an authorization code without going thru the browser and logging in?

Microsoft Security Microsoft Graph
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Mehtab Siddique (MINDTREE LIMITED) 971 Reputation points
    2023-01-01T12:57:45.21+00:00

    Hi @Ken Exton ,

    Here is documentation for getting the authorization and access without the user:

    275245-image.png

    For more information: https://learn.microsoft.com/en-us/graph/auth-v2-service

    ----------

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

    0 comments No comments

  2. CarlZhao-MSFT 46,371 Reputation points
    2023-01-02T08:05:57.673+00:00

    Hi @Ken Exton

    In short, it is impossible.

    The authorization code can only be obtained by interactively logging in the user in the browser. Refer to a high-level view of the authentication code flow:

    275382-image.png

    If you don't want to interact with users in the browser, then you can try ROPC flow. The ROPC flow doesn't require you to get an authorization code in the browser to redeem an access token, you just need to hardcode your username/password on the backend.

    275317-image.png

    Both of the above authentication flows require user participation to obtain a user token, if your context supports application-only permissions then you can also use the daemon-based client credentials flow.


    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.