Class: Telnyx::Resources::OAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/oauth.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ OAuth

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of OAuth.

Parameters:



205
206
207
# File 'lib/telnyx/resources/oauth.rb', line 205

def initialize(client:)
  @client = client
end

Instance Method Details

#grants(allowed:, consent_token:, request_options: {}) ⇒ Telnyx::Models::OAuthGrantsResponse

Create an OAuth authorization grant

Parameters:

  • allowed (Boolean)

    Whether the grant is allowed

  • consent_token (String)

    Consent token

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



39
40
41
42
43
44
45
46
47
48
# File 'lib/telnyx/resources/oauth.rb', line 39

def grants(params)
  parsed, options = Telnyx::OAuthGrantsParams.dump_request(params)
  @client.request(
    method: :post,
    path: "oauth/grants",
    body: parsed,
    model: Telnyx::Models::OAuthGrantsResponse,
    options: options
  )
end

#introspect(token:, request_options: {}) ⇒ Telnyx::Models::OAuthIntrospectResponse

Introspect an OAuth access token to check its validity and metadata

Parameters:

  • token (String)

    The token to introspect

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/telnyx/resources/oauth.rb', line 61

def introspect(params)
  parsed, options = Telnyx::OAuthIntrospectParams.dump_request(params)
  @client.request(
    method: :post,
    path: "oauth/introspect",
    headers: {"content-type" => "application/x-www-form-urlencoded"},
    body: parsed,
    model: Telnyx::Models::OAuthIntrospectResponse,
    options: options
  )
end

#register(client_name: nil, grant_types: nil, logo_uri: nil, policy_uri: nil, redirect_uris: nil, response_types: nil, scope: nil, token_endpoint_auth_method: nil, tos_uri: nil, request_options: {}) ⇒ Telnyx::Models::OAuthRegisterResponse

Register a new OAuth client dynamically (RFC 7591)

Parameters:

  • client_name (String)

    Human-readable string name of the client to be presented to the end-user

  • grant_types (Array<Symbol, Telnyx::Models::OAuthRegisterParams::GrantType>)

    Array of OAuth 2.0 grant type strings that the client may use

  • logo_uri (String)

    URL of the client logo

  • policy_uri (String)

    URL of the client’s privacy policy

  • redirect_uris (Array<String>)

    Array of redirection URI strings for use in redirect-based flows

  • response_types (Array<String>)

    Array of the OAuth 2.0 response type strings that the client may use

  • scope (String)

    Space-separated string of scope values that the client may use

  • token_endpoint_auth_method (Symbol, Telnyx::Models::OAuthRegisterParams::TokenEndpointAuthMethod)

    Authentication method for the token endpoint

  • tos_uri (String)

    URL of the client’s terms of service

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



100
101
102
103
104
105
106
107
108
109
# File 'lib/telnyx/resources/oauth.rb', line 100

def register(params = {})
  parsed, options = Telnyx::OAuthRegisterParams.dump_request(params)
  @client.request(
    method: :post,
    path: "oauth/register",
    body: parsed,
    model: Telnyx::Models::OAuthRegisterResponse,
    options: options
  )
end

#retrieve(consent_token, request_options: {}) ⇒ Telnyx::Models::OAuthRetrieveResponse

Retrieve details about an OAuth consent token

Parameters:

  • consent_token (String)

    OAuth consent token

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



17
18
19
20
21
22
23
24
# File 'lib/telnyx/resources/oauth.rb', line 17

def retrieve(consent_token, params = {})
  @client.request(
    method: :get,
    path: ["oauth/consent/%1$s", consent_token],
    model: Telnyx::Models::OAuthRetrieveResponse,
    options: params[:request_options]
  )
end

#retrieve_authorize(client_id:, redirect_uri:, response_type:, code_challenge: nil, code_challenge_method: nil, scope: nil, state: nil, request_options: {}) ⇒ nil

OAuth 2.0 authorization endpoint for the authorization code flow

Parameters:

Returns:

  • (nil)

See Also:



134
135
136
137
138
139
140
141
142
143
144
# File 'lib/telnyx/resources/oauth.rb', line 134

def retrieve_authorize(params)
  parsed, options = Telnyx::OAuthRetrieveAuthorizeParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "oauth/authorize",
    query: query,
    model: NilClass,
    options: options
  )
end

#retrieve_jwks(request_options: {}) ⇒ Telnyx::Models::OAuthRetrieveJwksResponse

Retrieve the JSON Web Key Set for token verification

Parameters:

Returns:

See Also:



155
156
157
158
159
160
161
162
# File 'lib/telnyx/resources/oauth.rb', line 155

def retrieve_jwks(params = {})
  @client.request(
    method: :get,
    path: "oauth/jwks",
    model: Telnyx::Models::OAuthRetrieveJwksResponse,
    options: params[:request_options]
  )
end

#token(grant_type:, client_id: nil, client_secret: nil, code: nil, code_verifier: nil, redirect_uri: nil, refresh_token: nil, scope: nil, request_options: {}) ⇒ Telnyx::Models::OAuthTokenResponse

Exchange authorization code, client credentials, or refresh token for access token

Parameters:

  • grant_type (Symbol, Telnyx::Models::OAuthTokenParams::GrantType)

    OAuth 2.0 grant type

  • client_id (String)

    OAuth client ID (if not using HTTP Basic auth)

  • client_secret (String)

    OAuth client secret (if not using HTTP Basic auth)

  • code (String)

    Authorization code (for authorization_code flow)

  • code_verifier (String)

    PKCE code verifier (for authorization_code flow)

  • redirect_uri (String)

    Redirect URI (for authorization_code flow)

  • refresh_token (String)

    Refresh token (for refresh_token flow)

  • scope (String)

    Space-separated list of requested scopes (for client_credentials)

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



190
191
192
193
194
195
196
197
198
199
200
# File 'lib/telnyx/resources/oauth.rb', line 190

def token(params)
  parsed, options = Telnyx::OAuthTokenParams.dump_request(params)
  @client.request(
    method: :post,
    path: "oauth/token",
    headers: {"content-type" => "application/x-www-form-urlencoded"},
    body: parsed,
    model: Telnyx::Models::OAuthTokenResponse,
    options: options
  )
end