Package credentials
Package credentials is an auto-generated package for the
IAM Service Account Credentials API.
Creates short-lived, limited-privilege credentials for IAM service
accounts.
General documentation
For information that is relevant for all client libraries please reference
https://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on this
page includes:
Example usage
To get started with this package, create a client.
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := credentials.NewIamCredentialsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
The client will use your default application credentials. Clients should be reused instead of created as needed.
The methods of Client are safe for concurrent use by multiple goroutines.
The returned client must be Closed when it is done being used.
Using the Client
The following is an example of making an API call with the newly created client.
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := credentials.NewIamCredentialsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &credentialspb.GenerateAccessTokenRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/iam/credentials/apiv1/credentialspb#GenerateAccessTokenRequest.
}
resp, err := c.GenerateAccessToken(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Use of Context
The ctx passed to NewIamCredentialsClient is used for authentication requests and
for creating the underlying connection, but is not used for subsequent calls.
Individual methods on the client use the ctx given to them.
To close the open connection, use the Close() method.
- func DefaultAuthScopes() []string
- type IamCredentialsCallOptions
- type IamCredentialsClient
- func NewIamCredentialsClient(ctx context.Context, opts ...option.ClientOption) (*IamCredentialsClient, error)
- func NewIamCredentialsRESTClient(ctx context.Context, opts ...option.ClientOption) (*IamCredentialsClient, error)
- func (c *IamCredentialsClient) Close() error
- func (c *IamCredentialsClient) Connection() *grpc.ClientConn
- func (c *IamCredentialsClient) GenerateAccessToken(ctx context.Context, req *credentialspb.GenerateAccessTokenRequest, opts ...gax.CallOption) (*credentialspb.GenerateAccessTokenResponse, error)
- func (c *IamCredentialsClient) GenerateIdToken(ctx context.Context, req *credentialspb.GenerateIdTokenRequest, opts ...gax.CallOption) (*credentialspb.GenerateIdTokenResponse, error)
- func (c *IamCredentialsClient) SignBlob(ctx context.Context, req *credentialspb.SignBlobRequest, opts ...gax.CallOption) (*credentialspb.SignBlobResponse, error)
- func (c *IamCredentialsClient) SignJwt(ctx context.Context, req *credentialspb.SignJwtRequest, opts ...gax.CallOption) (*credentialspb.SignJwtResponse, error)
Package files
auxiliary.go
doc.go
iam_credentials_client.go
version.go
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
IamCredentialsCallOptions contains the retry settings for each method of IamCredentialsClient.
type IamCredentialsCallOptions struct {
GenerateAccessToken []gax.CallOption
GenerateIdToken []gax.CallOption
SignBlob []gax.CallOption
SignJwt []gax.CallOption
}
IamCredentialsClient is a client for interacting with IAM Service Account Credentials API.
Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
A service account is a special type of Google account that belongs to your
application or a virtual machine (VM), instead of to an individual end user.
Your application assumes the identity of the service account to call Google
APIs, so that the users aren’t directly involved.
Service account credentials are used to temporarily assume the identity
of the service account. Supported credential types include OAuth 2.0 access
tokens, OpenID Connect ID tokens, self-signed JSON Web Tokens (JWTs), and
more.
type IamCredentialsClient struct {
CallOptions *IamCredentialsCallOptions
}
func NewIamCredentialsClient(ctx context.Context, opts ...option.ClientOption) (*IamCredentialsClient, error)
NewIamCredentialsClient creates a new iam credentials client based on gRPC.
The returned client must be Closed when it is done being used to clean up its underlying connections.
A service account is a special type of Google account that belongs to your
application or a virtual machine (VM), instead of to an individual end user.
Your application assumes the identity of the service account to call Google
APIs, so that the users aren’t directly involved.
Service account credentials are used to temporarily assume the identity
of the service account. Supported credential types include OAuth 2.0 access
tokens, OpenID Connect ID tokens, self-signed JSON Web Tokens (JWTs), and
more.
▾ Example
Code:
ctx := context.Background()
c, err := credentials.NewIamCredentialsClient(ctx)
if err != nil {
}
defer c.Close()
_ = c
func NewIamCredentialsRESTClient(ctx context.Context, opts ...option.ClientOption) (*IamCredentialsClient, error)
NewIamCredentialsRESTClient creates a new iam credentials rest client.
A service account is a special type of Google account that belongs to your
application or a virtual machine (VM), instead of to an individual end user.
Your application assumes the identity of the service account to call Google
APIs, so that the users aren’t directly involved.
Service account credentials are used to temporarily assume the identity
of the service account. Supported credential types include OAuth 2.0 access
tokens, OpenID Connect ID tokens, self-signed JSON Web Tokens (JWTs), and
more.
▾ Example
Code:
ctx := context.Background()
c, err := credentials.NewIamCredentialsRESTClient(ctx)
if err != nil {
}
defer c.Close()
_ = c
func (*IamCredentialsClient) Close
¶
func (c *IamCredentialsClient) Close() error
Close closes the connection to the API service. The user should invoke this when
the client is no longer required.
func (*IamCredentialsClient) Connection
¶
func (c *IamCredentialsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always
return the same resource.
func (c *IamCredentialsClient) GenerateAccessToken(ctx context.Context, req *credentialspb.GenerateAccessTokenRequest, opts ...gax.CallOption) (*credentialspb.GenerateAccessTokenResponse, error)
GenerateAccessToken generates an OAuth 2.0 access token for a service account.
▾ Example
Code:
ctx := context.Background()
c, err := credentials.NewIamCredentialsClient(ctx)
if err != nil {
}
defer c.Close()
req := &credentialspb.GenerateAccessTokenRequest{
}
resp, err := c.GenerateAccessToken(ctx, req)
if err != nil {
}
_ = resp
func (c *IamCredentialsClient) GenerateIdToken(ctx context.Context, req *credentialspb.GenerateIdTokenRequest, opts ...gax.CallOption) (*credentialspb.GenerateIdTokenResponse, error)
GenerateIdToken generates an OpenID Connect ID token for a service account.
▾ Example
Code:
ctx := context.Background()
c, err := credentials.NewIamCredentialsClient(ctx)
if err != nil {
}
defer c.Close()
req := &credentialspb.GenerateIdTokenRequest{
}
resp, err := c.GenerateIdToken(ctx, req)
if err != nil {
}
_ = resp
func (*IamCredentialsClient) SignBlob
¶
func (c *IamCredentialsClient) SignBlob(ctx context.Context, req *credentialspb.SignBlobRequest, opts ...gax.CallOption) (*credentialspb.SignBlobResponse, error)
SignBlob signs a blob using a service account’s system-managed private key.
▾ Example
Code:
ctx := context.Background()
c, err := credentials.NewIamCredentialsClient(ctx)
if err != nil {
}
defer c.Close()
req := &credentialspb.SignBlobRequest{
}
resp, err := c.SignBlob(ctx, req)
if err != nil {
}
_ = resp
func (*IamCredentialsClient) SignJwt
¶
func (c *IamCredentialsClient) SignJwt(ctx context.Context, req *credentialspb.SignJwtRequest, opts ...gax.CallOption) (*credentialspb.SignJwtResponse, error)
SignJwt signs a JWT using a service account’s system-managed private key.
▾ Example
Code:
ctx := context.Background()
c, err := credentials.NewIamCredentialsClient(ctx)
if err != nil {
}
defer c.Close()
req := &credentialspb.SignJwtRequest{
}
resp, err := c.SignJwt(ctx, req)
if err != nil {
}
_ = resp
Subdirectories