Skip to content

Promote OAuth2 service account to Jwt Access credentials #785

@anthmgoogle

Description

@anthmgoogle

Application Default Credentials can return Oauth2 service account credentials. gRPC can use more efficient JwtAccess credentials in place of this if no scopes have been specified. This tracks logic to detect this case and "promote" the credentials to JwtAccess form with the same identity properties if the OAuth2 form is passed in for use by gRPC.

Logic should be similar to this (in Java):

if (credentials instanceof ServiceAccountOAuth2Credentials) {
  ServiceAccountOAuth2Credentials serviceAccount = 
      (ServiceAccountOAuth2Credentials)credentials;
   if (serviceAccount.getScopes().length() == 0) {
     credentials = new ServiceAccountJwtAccessCredentials(
           serviceAccount.getAccountEmail(),
           serviceAccount.getPrivateKey(),
           serviceAccount.getPrivateKeyId());
   }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions