- 0.115.1 (latest)
- 0.115.0
- 0.114.0
- 0.113.0
- 0.112.2
- 0.111.0
- 0.110.10
- 0.109.0
- 0.108.0
- 0.107.0
- 0.106.0
- 0.105.0
- 0.104.0
- 0.103.0
- 0.102.1
- 0.101.1
- 0.100.2
- 0.99.0
- 0.98.0
- 0.97.0
- 0.96.0
- 0.95.0
- 0.94.1
- 0.93.3
- 0.92.3
- 0.91.1
- 0.90.0
- 0.89.0
- 0.88.0
- 0.87.0
- 0.86.0
- 0.85.0
- 0.84.0
- 0.83.0
- 0.82.0
- 0.81.0
- 0.80.0
- 0.79.0
- 0.78.0
- 0.77.0
- 0.76.0
- 0.75.0
Package credentials is an auto-generated package for the IAM Service Account Credentials API.
Creates short-lived, limited-privilege credentials for IAM service accounts.
Use of Context
The ctx passed to NewClient 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.
For information about setting deadlines, reusing contexts, and more please visit https://pkg.go.dev/cloud.google.com/go.
Functions
func DefaultAuthScopes
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
IamCredentialsCallOptions
type IamCredentialsCallOptions struct {
GenerateAccessToken []gax.CallOption
GenerateIdToken []gax.CallOption
SignBlob []gax.CallOption
SignJwt []gax.CallOption
}
IamCredentialsCallOptions contains the retry settings for each method of IamCredentialsClient.
IamCredentialsClient
type IamCredentialsClient struct {
// The call options for this service.
CallOptions *IamCredentialsCallOptions
// contains filtered or unexported fields
}
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.
func NewIamCredentialsClient
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
package main
import (
"context"
credentials "cloud.google.com/go/iam/credentials/apiv1"
)
func main() {
ctx := context.Background()
c, err := credentials.NewIamCredentialsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = 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.
func (*IamCredentialsClient) GenerateAccessToken
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
package main
import (
"context"
credentials "cloud.google.com/go/iam/credentials/apiv1"
credentialspb "google.golang.org/genproto/googleapis/iam/credentials/v1"
)
func main() {
ctx := context.Background()
c, err := credentials.NewIamCredentialsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &credentialspb.GenerateAccessTokenRequest{
// TODO: Fill request struct fields.
}
resp, err := c.GenerateAccessToken(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*IamCredentialsClient) GenerateIdToken
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
package main
import (
"context"
credentials "cloud.google.com/go/iam/credentials/apiv1"
credentialspb "google.golang.org/genproto/googleapis/iam/credentials/v1"
)
func main() {
ctx := context.Background()
c, err := credentials.NewIamCredentialsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &credentialspb.GenerateIdTokenRequest{
// TODO: Fill request struct fields.
}
resp, err := c.GenerateIdToken(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = 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
package main
import (
"context"
credentials "cloud.google.com/go/iam/credentials/apiv1"
credentialspb "google.golang.org/genproto/googleapis/iam/credentials/v1"
)
func main() {
ctx := context.Background()
c, err := credentials.NewIamCredentialsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &credentialspb.SignBlobRequest{
// TODO: Fill request struct fields.
}
resp, err := c.SignBlob(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = 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
package main
import (
"context"
credentials "cloud.google.com/go/iam/credentials/apiv1"
credentialspb "google.golang.org/genproto/googleapis/iam/credentials/v1"
)
func main() {
ctx := context.Background()
c, err := credentials.NewIamCredentialsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &credentialspb.SignJwtRequest{
// TODO: Fill request struct fields.
}
resp, err := c.SignJwt(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}