googleauth - Class Google::Auth::OAuth2::STSClient (v1.12.0)

Reference documentation and code samples for the googleauth class Google::Auth::OAuth2::STSClient.

OAuth 2.0 Token Exchange Spec. This module defines a token exchange utility based on the OAuth 2.0 Token Exchange spec. This will be mainly used to exchange external credentials for GCP access tokens in workload identity pools to access Google APIs. The implementation will support various types of client authentication as allowed in the spec.

A deviation on the spec will be for additional Google specific options that cannot be easily mapped to parameters defined in the RFC. The returned dictionary response will be based on the rfc8693 section 2.2.1 spec JSON response.

Inherits

  • Object

Methods

#exchange_token

def exchange_token(options = {}) -> Hash

Exchanges the provided token for another type of token based on the rfc8693 spec

A callable faraday instance used to make HTTP requests.

Parameters
  • connection (Faraday instance)
  • grant_type (String) — The OAuth 2.0 token exchange grant type.
  • subject_token (String) — The OAuth 2.0 token exchange subject token.
  • subject_token_type (String) — The OAuth 2.0 token exchange subject token type.
  • resource (String) — The optional OAuth 2.0 token exchange resource field.
  • audience (String) — The optional OAuth 2.0 token exchange audience field.
  • scopes (Array<String>) — The optional list of scopes to use.
  • requested_token_type (String) — The optional OAuth 2.0 token exchange requested token type.
  • additional_headers (Hash<String,String>) — : The optional additional headers to pass to the token exchange endpoint.
Returns
  • (Hash) — A hash containing the token exchange response.

#initialize

def initialize(options = {}) -> STSClient

Create a new instance of the STSClient.

Parameter
  • token_exchange_endpoint (String) — The token exchange endpoint.
Returns
  • (STSClient) — a new instance of STSClient

Constants

URLENCODED_HEADERS

value: { "Content-Type": "application/x-www-form-urlencoded" }.freeze