By default, this returns an instance ofGoogle::Iam::Credentials::V1::IAMCredentials::Clientfor a gRPC client for version V1 of the API.
However, you can specify a different API version by passing it in theversionparameter. If the IAMCredentials service is
supported by that API version, and the corresponding gem is available, the
appropriate versioned client will be returned.
You can also specify a different transport by passing:restor:grpcin
thetransportparameter.
Raises an exception if the currently installed versioned client gem for the
given API version does not support the given transport of the IAMCredentials service.
You can determine whether the method will succeed by callingCredentials.iam_credentials_available?.
About IAMCredentials
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.
Parameters
version(::String, ::Symbol)(defaults to: :v1)— The API version to connect to. Optional.
Defaults to:v1.
transport(:grpc, :rest)(defaults to: :grpc)— The transport to use. Defaults to:grpc.
Returns
(::Object) — A client object for the specified version.
Determines whether the IAMCredentials service is supported by the current client.
If true, you can retrieve a client object by callingCredentials.iam_credentials.
If false, that method will raise an exception. This could happen if the given
API version does not exist or does not support the IAMCredentials service,
or if the versioned client gem needs an update to support the IAMCredentials service.
Parameters
version(::String, ::Symbol)(defaults to: :v1)— The API version to connect to. Optional.
Defaults to:v1.
transport(:grpc, :rest)(defaults to: :grpc)— The transport to use. Defaults to:grpc.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# IAM Service Account Credentials API - Module Google::Iam::Credentials (v1.5.1)\n\nVersion latestkeyboard_arrow_down\n\n- [1.5.1 (latest)](/ruby/docs/reference/google-iam-credentials/latest/Google-Iam-Credentials)\n- [1.5.0](/ruby/docs/reference/google-iam-credentials/1.5.0/Google-Iam-Credentials)\n- [1.4.1](/ruby/docs/reference/google-iam-credentials/1.4.1/Google-Iam-Credentials)\n- [1.3.0](/ruby/docs/reference/google-iam-credentials/1.3.0/Google-Iam-Credentials)\n- [1.2.0](/ruby/docs/reference/google-iam-credentials/1.2.0/Google-Iam-Credentials)\n- [1.1.0](/ruby/docs/reference/google-iam-credentials/1.1.0/Google-Iam-Credentials)\n- [1.0.3](/ruby/docs/reference/google-iam-credentials/1.0.3/Google-Iam-Credentials) \nReference documentation and code samples for the IAM Service Account Credentials API module Google::Iam::Credentials.\n\nMethods\n-------\n\n### .iam_credentials\n\n def self.iam_credentials(version: :v1, transport: :grpc, &block) -\u003e ::Object\n\nCreate a new client object for IAMCredentials.\n\n\nBy default, this returns an instance of\n[Google::Iam::Credentials::V1::IAMCredentials::Client](https://cloud.google.com/ruby/docs/reference/google-iam-credentials-v1/latest/Google-Iam-Credentials-V1-IAMCredentials-Client)\nfor a gRPC client for version V1 of the API.\nHowever, you can specify a different API version by passing it in the\n`version` parameter. If the IAMCredentials service is\nsupported by that API version, and the corresponding gem is available, the\nappropriate versioned client will be returned.\nYou can also specify a different transport by passing `:rest` or `:grpc` in\nthe `transport` parameter.\n\nRaises an exception if the currently installed versioned client gem for the\ngiven API version does not support the given transport of the IAMCredentials service.\nYou can determine whether the method will succeed by calling\n[Credentials.iam_credentials_available?](/ruby/docs/reference/google-iam-credentials/latest/Google-Iam-Credentials#Google__Iam__Credentials_iam_credentials_available__class_ \"Google::Iam::Credentials.iam_credentials_available? (method)\").\n\n#### About IAMCredentials\n\nA service account is a special type of Google account that belongs to your\napplication or a virtual machine (VM), instead of to an individual end user.\nYour application assumes the identity of the service account to call Google\nAPIs, so that the users aren't directly involved.\n\n\u003cbr /\u003e\n\nService account credentials are used to temporarily assume the identity\nof the service account. Supported credential types include OAuth 2.0 access\ntokens, OpenID Connect ID tokens, self-signed JSON Web Tokens (JWTs), and\nmore. \n**Parameters**\n\n- **version** (::String, ::Symbol) *(defaults to: :v1)* --- The API version to connect to. Optional. Defaults to `:v1`.\n- **transport** (:grpc, :rest) *(defaults to: :grpc)* --- The transport to use. Defaults to `:grpc`. \n**Returns**\n\n- (::Object) --- A client object for the specified version.\n\n### .iam_credentials_available?\n\n def self.iam_credentials_available?(version: :v1, transport: :grpc) -\u003e boolean\n\nDetermines whether the IAMCredentials service is supported by the current client.\nIf true, you can retrieve a client object by calling [Credentials.iam_credentials](/ruby/docs/reference/google-iam-credentials/latest/Google-Iam-Credentials#Google__Iam__Credentials_iam_credentials_class_ \"Google::Iam::Credentials.iam_credentials (method)\").\nIf false, that method will raise an exception. This could happen if the given\nAPI version does not exist or does not support the IAMCredentials service,\nor if the versioned client gem needs an update to support the IAMCredentials service. \n**Parameters**\n\n- **version** (::String, ::Symbol) *(defaults to: :v1)* --- The API version to connect to. Optional. Defaults to `:v1`.\n- **transport** (:grpc, :rest) *(defaults to: :grpc)* --- The transport to use. Defaults to `:grpc`. \n**Returns**\n\n- (boolean) --- Whether the service is available.\n\nConstants\n---------\n\n### VERSION\n\n**value:**\"1.5.1\""]]