Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
This one is the error which i am getting every time :

"Error:"unauthorized_client", Description:"Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested.", Uri:"


Code :

var certificate = new X509Certificate2(Server.MapPath("folder/serviceaccountgenratedcredecialfile.p12"), "notasecret", X509KeyStorageFlags.Exportable);
         var credential = new ServiceAccountCredential(new ServiceAccountCredential
         .Initializer("service-account-email@my-project-name.iam.gserviceaccount.com")
         {

             Scopes = new[] { "https://mail.google.com/" },
             User = "user-email@gmail.com"
         }.FromCertificate(certificate));

         bool result =  credential.RequestAccessTokenAsync(CancellationToken.None).Result;


What I have tried:

I have tried every possible solution which is available on google.
Posted
Updated 27-Sep-19 9:26am
Comments
ZurdoDev 27-Sep-19 10:49am    
It just means you aren't accessing the resource correctly. What can we do?

1 solution

Maybe you can use the Auth0 service: identity-and-access-management-services~auth0[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900