Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Reading in runtime access tokens from table, and then calling api calls with different tokens/users #2264

Closed
stefancvetkovic opened this issue Dec 21, 2023 · 2 comments

Comments

@stefancvetkovic
Copy link

Hello,

I want to sync my .net calendar to office365 calendar.
I will use:

  • standard http endpoint and authorization code flow for obtaining access token and refresh token
  • these token then I will store at my db
  • after that, when it comes request (because its azure function), I need to perform some operation, for example to create a new Event on Calendar365.
  • I will get my token, or refresh token from db and use GraphApi SDK in order to obtain these data.

Now I discovered how to pass accessToken and initialize a GraphServiceClient:

public GraphServiceClient GetAuthenticatedGraphClient(string accessToken)
{
    if (!string.IsNullOrEmpty(accessToken))
    {
        return new GraphServiceClient(new AuthenticationProvider(accessToken));
    }
    else
    {
        throw new Exception("AccessToken is not populated.");
    }
}

So for each recevied event from my local queue, I need to trigger some method which will for some particular user grab the token, and call GraphAPI.
Should I go for Singleton instance and then just re-enter the access token? any concerns about that?
Is there a way to put in builder service some code which tells application to obtain the code automaticaly?
Thanks

@andrueastman
Copy link
Member

Apologise for the delayed response @stefancvetkovic

I believe the Identity.Web library is best suited for such scenarios as it supports token serialization and intergrates well with this library.

Any chance you've taken a look at the docs at https://github.com/AzureAD/microsoft-identity-web/wiki

Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants