Class: Auth0::Clients::Credentials::Client
- Inherits:
-
Object
- Object
- Auth0::Clients::Credentials::Client
- Defined in:
- lib/auth0/clients/credentials/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Auth0::Types::PostClientCredentialResponseContent
Create a client credential associated to your application.
-
#delete(request_options: {}, **params) ⇒ untyped
Delete a client credential you previously created.
-
#get(request_options: {}, **params) ⇒ Auth0::Types::GetClientCredentialResponseContent
Get the details of a client credential.
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Array[Auth0::Types::ClientCredential]
Get the details of a client credential.
-
#update(request_options: {}, **params) ⇒ Auth0::Types::PatchClientCredentialResponseContent
Change a client credential you previously created.
Constructor Details
#initialize(client:) ⇒ void
10 11 12 |
# File 'lib/auth0/clients/credentials/client.rb', line 10 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Auth0::Types::PostClientCredentialResponseContent
Create a client credential associated to your application. Credentials can be used to configure Private Key JWT and mTLS authentication methods, as well as for JWT-secured Authorization requests.
Public Key
Public Key credentials can be used to set up Private Key JWT client authentication and JWT-secured Authorization requests.
Sample:
{
"credential_type": "public_key",
"name": "string",
"pem": "string",
"alg": "RS256",
"parse_expiry_from_cert": false,
"expires_at": "2022-12-31T23:59:59Z"
}
Certificate (CA-signed & self-signed)
Certificate credentials can be used to set up mTLS client authentication. CA-signed certificates can be configured either with a signed certificate or with just the certificate Subject DN.
CA-signed Certificate Sample (pem):
{
"credential_type": "x509_cert",
"name": "string",
"pem": "string"
}
CA-signed Certificate Sample (subject_dn):
{
"credential_type": "cert_subject_dn",
"name": "string",
"subject_dn": "string"
}
Self-signed Certificate Sample:
{
"credential_type": "cert_subject_dn",
"name": "string",
"pem": "string"
}
The credential will be created but not yet enabled for use until you set the corresponding properties in the client:
- To enable the credential for Private Key JWT or mTLS authentication methods, set the
client_authentication_methodsproperty on the client. For more information, read Configure Private Key JWT Authentication and Configure mTLS Authentication - To enable the credential for JWT-secured Authorization requests, set the
signed_request_objectproperty on the client. For more information, read Configure JWT-secured Authorization Requests (JAR)
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/auth0/clients/credentials/client.rb', line 138 def create(request_options: {}, **params) params = Auth0::Internal::Types::Utils.normalize_keys(params) request_data = Auth0::Clients::Credentials::Types::PostClientCredentialRequestContent.new(params).to_h non_body_param_names = %w[client_id] body = request_data.except(*non_body_param_names) request = Auth0::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "clients/#{URI.encode_uri_component(params[:client_id].to_s)}/credentials", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Auth0::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) (response.body.to_s.empty? ? nil : Auth0::Types::PostClientCredentialResponseContent.load(response.body)) else error_class = Auth0::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#delete(request_options: {}, **params) ⇒ untyped
Delete a client credential you previously created. May be enabled or disabled. For more information, read Client Credential Flow.
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/auth0/clients/credentials/client.rb', line 231 def delete(request_options: {}, **params) params = Auth0::Internal::Types::Utils.normalize_keys(params) request = Auth0::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "clients/#{URI.encode_uri_component(params[:client_id].to_s)}/credentials/#{URI.encode_uri_component(params[:credential_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Auth0::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Auth0::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#get(request_options: {}, **params) ⇒ Auth0::Types::GetClientCredentialResponseContent
Get the details of a client credential.
Important: To enable credentials to be used for a client authentication method, set the
client_authentication_methods property on the client. To enable credentials to be used for JWT-Secured
Authorization requests set the signed_request_object property on the client.
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/auth0/clients/credentials/client.rb', line 188 def get(request_options: {}, **params) params = Auth0::Internal::Types::Utils.normalize_keys(params) request = Auth0::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "clients/#{URI.encode_uri_component(params[:client_id].to_s)}/credentials/#{URI.encode_uri_component(params[:credential_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Auth0::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) (response.body.to_s.empty? ? nil : Auth0::Types::GetClientCredentialResponseContent.load(response.body)) else error_class = Auth0::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list(request_options: {}, **params) ⇒ Array[Auth0::Types::ClientCredential]
Get the details of a client credential.
Important: To enable credentials to be used for a client authentication method, set the
client_authentication_methods property on the client. To enable credentials to be used for JWT-Secured
Authorization requests set the signed_request_object property on the client.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/auth0/clients/credentials/client.rb', line 33 def list(request_options: {}, **params) params = Auth0::Internal::Types::Utils.normalize_keys(params) request = Auth0::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "clients/#{URI.encode_uri_component(params[:client_id].to_s)}/credentials", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Auth0::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Auth0::Internal::Types::Utils.coerce(Internal::Types::Array[Auth0::Types::ClientCredential], (response.body.to_s.empty? ? nil : JSON.parse(response.body, symbolize_names: true))) else error_class = Auth0::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update(request_options: {}, **params) ⇒ Auth0::Types::PatchClientCredentialResponseContent
Change a client credential you previously created. May be enabled or disabled. For more information, read Client Credential Flow.
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/auth0/clients/credentials/client.rb', line 272 def update(request_options: {}, **params) params = Auth0::Internal::Types::Utils.normalize_keys(params) request_data = Auth0::Clients::Credentials::Types::PatchClientCredentialRequestContent.new(params).to_h non_body_param_names = %w[client_id credential_id] body = request_data.except(*non_body_param_names) request = Auth0::Internal::JSON::Request.new( base_url: [:base_url], method: "PATCH", path: "clients/#{URI.encode_uri_component(params[:client_id].to_s)}/credentials/#{URI.encode_uri_component(params[:credential_id].to_s)}", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Auth0::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) (response.body.to_s.empty? ? nil : Auth0::Types::PatchClientCredentialResponseContent.load(response.body)) else error_class = Auth0::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |