I am trying to generate authProvider for onedrive api using Graph API in asp.net MVC c# but i am getting the following error.
When I used AuthorizationCodeProvider then i will get bellow error:
private const string ClientId = "87b15343-d439-4e15-b6da-e0cd4c6f5acd";
string clientSecret = "uxhNa4_4_~2eT4xM-E8BuoJr2EqGbif5.2";
static IEnumerable<string> scopes = new List<string> {
"Files.Read",
"Files.Read.All",
"Files.ReadWrite",
"Files.ReadWrite.All",
"Mail.Read",
"Mail.ReadBasic",
"Mail.ReadWrite"
};
IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(ClientId)
.WithRedirectUri("https://localhost:44382")
.WithClientSecret(clientSecret) // or .WithCertificate(certificate)
.Build();
AuthorizationCodeProvider authProvider = new AuthorizationCodeProvider(confidentialClientApplication, scopes);
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
IDriveItemChildrenCollectionPage DriveItem = await graphClient.Me.Drive.Root.Children.Request().GetAsync();
And Then after i got some Links and changed my code according that. but still im getting error.
Link : https://stackoverflow.com/questions/62142905/using-graphserviceclient-to-retrieve-group-info-of-azure-ad-members
IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(ClientId)
.WithRedirectUri("https://localhost:44382")
.WithClientSecret(clientSecret) // or .WithCertificate(certificate)
.Build();
ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication);
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
IDriveItemChildrenCollectionPage DriveItem = await graphClient.Me.Drive.Root.Children.Request().GetAsync();
But i'm passing access token directly from graph-explorer then its work fine.
Can someone help in fixing this issue.