-
Notifications
You must be signed in to change notification settings - Fork 263
Closed
Labels
Status: No recent activitystatus:waiting-for-author-feedbackIssue that we've responded but needs author feedback to closeIssue that we've responded but needs author feedback to close
Description
private GraphServiceClient InitializeServiceForMSGraph(string accessTokenFromHeader)
{
// Your existing code to extract the access token from the request headers
var accessToken = accessTokenFromHeader.Substring("Bearer ".Length);
// Create a TokenCredential using the access token
var tokenCredential = new **AccessTokenCredential**(accessToken);
// Initialize the GraphServiceClient with the TokenCredential
var graphServiceClient = new GraphServiceClient((tokenCredential);
return graphServiceClient;
}
With the above code, its unable to find a reference to AccessTokenCredential.
Second approach tried was as below
var authProvider = new DelegateAuthenticationProvider(async (requestMessage) =>
{
// Set the Authorization header with the access token
requestMessage.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken);
});
var appGraphClient = new GraphServiceClient(authProvider);
return appGraphClient;
With this approach, I am getting an error on DelegateAuthenticationProvider which seems to have being deprecated by Microsoft
Metadata
Metadata
Assignees
Labels
Status: No recent activitystatus:waiting-for-author-feedbackIssue that we've responded but needs author feedback to closeIssue that we've responded but needs author feedback to close