Hello,
I'm using the Google Drive C# API, and have a web site (Blazor, .NET5 in case it makes any difference) that has been working fine. I was using the client's Google credentials for this, had downloaded a JSON file (following instructions here) and all was well. When I first ran the web site in Visual Studio, I got the Google auth screen, in which I entered his email and password, and it worked. This created a JSON file in my web site which then allowed me to run the site next time without having to auth again.
In the credentials JSON file, I added the redirect URI, using the URI that VS uses when I debug the site. This gave me JSON file like this...
{ "web": { "client_id": "xxxxxxxxxxxxxxxx", "project_id": "xxxxxxxxxxxxxxx", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_secret": "xxxxxxxxxxxxxxxxxxxxx", "redirect_uris": [ "https://localhost:44378/authorize/", "https://localhost:44378/authorize" ] } }
The code I use to create the Google service is quite closely copied from their .NET Quickstart (step 2)...
UserCredential credential; using (FileStream stream = new(credJson, FileMode.Open, FileAccess.Read)) { credential = GoogleWebAuthorizationBroker .AuthorizeAsync(GoogleClientSecrets.FromStream(stream).Secrets, new[] { DriveService.Scope.Drive }, "user", CancellationToken.None, new FileDataStore(tokenPath, true)) .Result; } DriveService service = new(new BaseClientService.Initializer { HttpClientInitializer = credential, ApplicationName = "" });
That all worked fine. Now the client has set up another Google account specially for this site, and wants me to use that instead. No problem, I went to the Google developer console for the new account and did the same as before, ie configured the OAuth screen, created a new OAuth credential, downloaded the JSON file, added the redirect URIs as shown above, and replaced the existing JSON file with the new one.
When I try to debug, I get the error shown in the title.
Having spent hours researching this error, I have checked and double-checked the following...
None of this helped, I always get the same error.
The weird thing is that if I now revert my credentials JSON file back to what it was before (with the client's own Google account), I get the same error.
Anyone any ideas? As far as I can see, I've tried everything suggested, but still get this error.
Thanks
Hello! Did you solve this problem? I have the same issue right now and I don't know what I can do