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.

It's too difficult to create a client with anything but application Credentials.

See original GitHub issue

For all our APIs, it should be simple to create a client with

  1. Default application credentials. (implicitly)
  2. A path to .json credentials.
  3. Explicitly request Compute Engine credentials.

For an example, see the CloudLibrary class in https://github.com/GoogleCloudPlatform/dotnet-docs-samples/blob/master/auth/AuthSample/Program.cs.

In Pubsub, it was too difficult to create a client with a path to .json credentials:

 public static PublisherClient CreatePublisherWithServiceCredentials(string jsonPath)
        {
            GoogleCredential googleCredential = null;
            using (var jsonStream = new FileStream(jsonPath, FileMode.Open,
                FileAccess.Read, FileShare.Read))
            {
                googleCredential = GoogleCredential.FromStream(jsonStream)
                    .CreateScoped(PublisherClient.DefaultScopes);

                
            }

            return PublisherClient.Create(new Channel(PublisherClient.DefaultEndpoint.Host, PublisherClient.DefaultEndpoint.Port, googleCredential.ToChannelCredentials()));
        }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:17 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jskeetcommented, Apr 18, 2019

Note: Google.Cloud.Datastore.V1 2.2.0-beta02 now includes a DatastoreClientBuilder and a DatastoreDbBuilder to show how this can be done more generally.

2reactions
jskeetcommented, Oct 24, 2017

I’m working on getting scopeless credentials fixed for gRPC clients. #1580 helps track how widespread the problem is. @LindaLawton the good news is that it seems to work for PubSub, so at least there you wouldn’t have a problem.

I beginning to wonder whether a simple CreateFromCredentialsFile(string file, FooSettings = null) method is the simplest fix here. I assume that having a file is the most common situation here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to protect client credentials in a desktop app?
This is a known issue with desktop applications. You need to ensure first of all that your client id and client secrete are...
Read more >
Create client credential for Azure AD's App registration
I created a new ASP.NET Core MVC 6.0 web application >> and i define it to use Azure AD for authentication, as follow:-....
Read more >
Set up Application Default Credentials | Authentication
Application Default Credentials. Set up Application Default Credentials · How Application Default Credentials works · Troubleshoot your ADC setup.
Read more >
Abusing Azure Application Credentials to Attack Supply ...
Conclusion. Attacks that abuse application permissions by compromising the application's owner are very difficult to detect. Organizations creating multi-tenant ...
Read more >
API authentication and authorization best practices
Client authentication is vastly different from user authentication. Clients are automated, so authenticating them on every request to the API is ...
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