GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Inconsistency in credentials specification for CPS Publisher and Subscriber · Issue #1959 · googleapis/google-cloud-java

Inconsistency in credentials specification for CPS Publisher and Subscriber #1959

New issue
Copy link
New issue
Copy link
Closed
Closed
Inconsistency in credentials specification for CPS Publisher and Subscriber#1959
Copy link
Assignees
garrettjonesgoogle
Labels
api: pubsubIssues related to the Pub/Sub API.

Description

@kamalaboulhosn
kamalaboulhosn
opened on Apr 21, 2017
Issue body actions

Both the Publisher and the Subscriber class state "If no credentials are provided, the [Publisher|Subscriber] will use application default creentials through GoogleCredentials#getApplicationDefault. However, while Subscriber.Builder has a setCredentials method, Publisher.Builder does not. Moreover, from what I can see, Subscriber does not actually use the credentials set via Subscriber.Builder.setCredentials. If we are going to allow one to set credentials this way, we should be consistent between the Publisher and Subscriber and ensure we use the provided credentials. Otherwise, we should remove the method from the Subscriber.Builder.

Activity

  1. garrettjonesgoogle
    added
    api: pubsubIssues related to the Pub/Sub API.
    Status: Beta Blocking
    on Apr 21, 2017
  2. was2 commented on Apr 22, 2017

    @was2
    was2
    on Apr 22, 2017
    More actions

    I am seeing the same behavior with Subscriber.Builder.setCrecentials - even when valid creds are provided, I get an error complaining that app default credentials are not available. This appears to have started in 0.13.0.

  3. garrettjonesgoogle commented on Apr 23, 2017

    @garrettjonesgoogle
    garrettjonesgoogle
    on Apr 23, 2017
    Contributor
    More actions

    gRPC has a way to provide credentials through CallOptions, which is currently marked with @ExperimentalApi, but that will be removed soon. This enables us to change how credentials are provided to GAPIC clients: we could move CredentialsProvider fromChannelProvider up to ClientSettings (so that it is a sibling of ChannelProvider). This would make the code to provide custom credentials a bit simpler. Then, this same design could be used in Publisher/Subscriber, where credentials are provided separately from the channel.

    Current code:

    CredentialsProvider credentialsProvider =
        FixedCredentialsProvider
            .create(ServiceAccountCredentials.fromStream(new FileInputStream("credentials.json")));
    ChannelProvider channelProvider =
        TopicAdminSettings.defaultChannelProviderBuilder()
            .setCredentialsProvider(credentialsProvider).build();
    TopicName topicName = TopicName.create("my-project-id", "my-topic-id");
    Publisher publisher =
        Publisher.defaultBuilder(topicName).setChannelProvider(channelProvider).build();
    

    Proposed:

    CredentialsProvider credentialsProvider =
        FixedCredentialsProvider
            .create(ServiceAccountCredentials.fromStream(new FileInputStream("credentials.json")));
    TopicName topicName = TopicName.create("my-project-id", "my-topic-id");
    Publisher publisher =
        Publisher.defaultBuilder(topicName).setCredentialsProvider(credentialsProvider).build();
    

    @pongad what are your thoughts?

  4. pongad
    self-assigned this
    on Apr 24, 2017
  5. pongad commented on Apr 24, 2017

    @pongad
    pongad
    on Apr 24, 2017
    Contributor
    More actions

    This was missed when we migrate from ChannelBuilder to ChannelProvider. The method setCredentials weren't removed but calling it is essentially a noop.

    @garrettjonesgoogle My understanding of credentials is that we put an interceptor into the channel, and the interceptor insert credentials into calls. If the CredentialsProvider is a sibling of the ChannelProvider, how does the ChannelProvider create a channel without knowing what the credentials are? In general, I think Subscriber/Publisher should use the same "credential inserter" as gapic clients. Or do we plan to change those too?

    In either case, I think we can all agree that the doc and method are misleading and should be removed. I'll make a PR for this.

  6. garrettjonesgoogle commented on Apr 24, 2017

    @garrettjonesgoogle
    garrettjonesgoogle
    on Apr 24, 2017
    Contributor
    More actions

    @pongad we would no longer use an interceptor; we would add a new UnaryCallable in the stack which adds the credentials to CallOptions before calling the next UnaryCallable. In that way, the credentials and the channel are decoupled.

    I agree that Subscriber/Publisher should use the same mechanism as GAPIC clients.

  7. pongad commented on Apr 24, 2017

    @pongad
    pongad
    on Apr 24, 2017
    Contributor
    More actions

    Ah OK. I assume this new layer hasn't been written yet? I'll make a PR to remove this old code. When the layer is ready, we can migrate en masse.

  8. garrettjonesgoogle commented on Apr 24, 2017

    @garrettjonesgoogle
    garrettjonesgoogle
    on Apr 24, 2017
    Contributor
    More actions

    @pongad correct, support for this is not written yet into GAX or toolkit.

  9. garrettjonesgoogle
    added a commit that references this issue on Apr 28, 2017

    pubsub: delete Subscriber.Builder::setCredentials (#1975)

    a740201
  10. garrettjonesgoogle
    closed this as completedin #2019on Apr 28, 2017
  11. theacodes
    unassigned
    pongad
    on Sep 28, 2018
  12. JustinBeckwith
    assigned
    garrettjonesgoogle
    on Feb 1, 2021
  13. chingor13
    added a commit that references this issue on Feb 20, 2026

    chore(main): release 2.28.5-SNAPSHOT (#1959)

    3722234
  14. suztomo
    added a commit that references this issue on Mar 23, 2026

    deps: update dependency com.google.cloud:google-cloud-trace to v2.60.0 (

    f19a5e1
  15. meltsufin
    added 2 commits that reference this issue on Apr 29, 2026

    chore(main): release 1.127.3 (#1959)

    e49cdc4

    chore(main): release 1.127.3 (#1959)

    fd73ca3
  16. benjaminp
    added 2 commits that reference this issue on Jul 13, 2026

    feat: Add APIs to enable request priorities (googleapis#1959)

    b45333c

    chore(main): release 2.29.0 (googleapis#1969)

    bb2ffba
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @garrettjonesgoogle
    garrettjonesgoogle

Labels

api: pubsubIssues related to the Pub/Sub API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.