Skip to content

Commit

Permalink
fix: add scope codes to the stub provider
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahrogers-google authored Apr 16, 2020
1 parent f14da77 commit 12d2a0e
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package com.google.cloud.pubsublite;

import com.google.auth.oauth2.GoogleCredentials;
import com.google.common.collect.ImmutableList;
import io.grpc.Channel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.auth.MoreCallCredentials;
Expand All @@ -23,11 +24,17 @@
import java.util.function.Function;

public class Stubs {
private static final ImmutableList<String> DEFAULT_SERVICE_SCOPES =
ImmutableList.of("https://www.googleapis.com/auth/cloud-platform");

public static <StubT extends AbstractStub<StubT>> StubT defaultStub(
String target, Function<Channel, StubT> stubFactory) throws IOException {
return stubFactory
.apply(ManagedChannelBuilder.forTarget(target).build())
.withCallCredentials(MoreCallCredentials.from(GoogleCredentials.getApplicationDefault()));
.withCallCredentials(MoreCallCredentials.from(
GoogleCredentials
.getApplicationDefault()
.createScoped(DEFAULT_SERVICE_SCORES)));
}

private Stubs() {}
Expand Down

0 comments on commit 12d2a0e

Please sign in to comment.