How to perform authorization code flow in my Typescript module with no access to the actual web application source?

Thakur, Saumya 20 Reputation points
2025-06-16T11:32:26.7833333+00:00

Hello,

So, I wish to include the Authorization Code Flow of Microsoft Graph in my application's module's source code. I went through the reference: https://learn.microsoft.com/en-us/graph/auth-v2-user?tabs=http and I understood the process but the issue is I do not have access to my application's source code (Hence, there is no index.js file to start the application and through which I can define the routes and the APIs). Maybe I am misunderstanding this but I'd really appreciate any help on how to code this whole flow in a few functions (I understand a single function also will not be possible because of the involved callback).

--> I cannot directly write an app.get() API to obtain the code from the redirect URI.

--> I would like to include all the callbacks in those functions itself somehow.

Is this possible? My code currently works with the accessToken obtained from the GraphExplorer. It is hard-coded in the configuration files and the application is working fine with that token. I just need to replace that hard-coded part and include an automated flow to obtain that token. I checked the MSAL library and as far as I could understand, it also will require a callback.

--> My application is actually an MS Teams Bot and I need this token to access the calendar's of other Users in order to perform some scheduling tasks.

--> The development language is TypeScript.

I look forward to the response and would be happy to provide any other details if needed.

Thanks in advance!

@Rukmini please find the question here, thanks!

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,690 questions
{count} votes

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.