At least one client secrets (Installed or Web) should be set
See original GitHub issueI’m trying to create a token using a JSON service account private key file, and no matter what I do the GoogleWebAuthorizationBroker keeps giving the following error.
At least one client secrets (Installed or Web) should be set
Why is the broker asking for a client secret? Isn’t that the whole purpose of a service account with domain wide delegated permissions?
using System;
using System.IO;
using System.Threading;
using Google.Apis.Admin.Directory.directory_v1;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Util.Store;
class Program
{
// If modifying these scopes, delete your previously saved credentials
// at ~/.credentials/admin-directory_v1-dotnet-quickstart.json
static string[] Scopes = { DirectoryService.Scope.AdminDirectoryDeviceChromeos };
static string ApplicationName = "TokenStore";
static void Main(string[] args)
{
UserCredential credential;
using (var stream =
new FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "client_secret.json"), FileMode.Open, FileAccess.Read))
{
string credPath = AppDomain.CurrentDomain.BaseDirectory;
credPath = Path.Combine(credPath, "\\token.json");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
Console.WriteLine("Credential file saved to: " + credPath);
}
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Google Oauth error: At least one client secrets (Installed or ...
When I run it, I get this error: At least one client secrets (Installed or Web) should be set. However, in my json...
Read more >Client Secrets | API Client Library for .NET
The Google APIs client library for .NET uses client_secrets.json files for storing the client_id , client_secret , and other OAuth 2.0 ...
Read more >Google Oauth error: At least one client secrets (Installed or ...
C# – Google Oauth error: At least one client secrets (Installed or Web) should be set. I'm using Google's Oauth 2.0 to upload...
Read more >Google Oauth error: At least one client secrets (Installed or ...
Coding example for the question Google Oauth error: At least one client secrets (Installed or Web) should be set.
Read more >OAuth 2.0 for Google Regular Accounts (installed ...
Do the authorization using Client ID and Client Secret issued by Google to our application. At the first time, this will open the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh right, I see. The code is mixing up service credentials and oauth credentials. I thought you were wanting to use oauth, but if you’ve downloaded a service credential then don’t use
GoogleWebAuthorizationBroker
, that’s for oauth. Create a credential like this:var cred = GoogleCredentials.FromFile(<path to file>).CreateScoped(<scopes you require>);
.It’s in the nuget package
Google.Apis.Auth
; and the fully-qualified name isGoogle.Apis.Auth.OAuth2.GoogleCredential
. Here’s the source-code: https://github.com/googleapis/google-api-dotnet-client/blob/aadabafd8ec8c3118e5f71e388ccb3718ee2e002/Src/Support/Google.Apis.Auth/OAuth2/GoogleCredential.cs