question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

At least one client secrets (Installed or Web) should be set

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
chrisdunelmcommented, Nov 9, 2018

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>);.

3reactions
chrisdunelmcommented, Nov 11, 2018

It’s in the nuget package Google.Apis.Auth; and the fully-qualified name is Google.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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found