Method: Auth0::Api::AuthenticationEndpoints#login_with_resource_owner

Defined in:
lib/auth0/api/authentication_endpoints.rb

#login_with_resource_owner(login_name, password, client_id: @client_id, client_secret: @client_secret, realm: nil, audience: nil, scope: 'openid') ⇒ json

rubocop:disable Metrics/ParameterLists Get access and ID tokens using Resource Owner Password. Requires that your tenant has a Default Audience or Default Directory.

Parameters:

  • login_name (string)

    Email or username for the connection

  • password (string)

    Password

  • client_id (string) (defaults to: @client_id)

    Client ID for the application

  • client_secret (string) (defaults to: @client_secret)

    Client secret for the application. Ignored if using Client Assertion

  • realm (string) (defaults to: nil)

    Specific realm to authenticate against

  • audience (string) (defaults to: nil)

    API audience

  • scope (string) (defaults to: 'openid')

    Scope(s) requested

    • Include an audience (above) for API access scopes

    • Use the default “openid” for userinfo calls

Returns:

  • (json)

    Returns the access_token and id_token

Raises:

See Also:



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/auth0/api/authentication_endpoints.rb', line 155

def (
  ,
  password,
  client_id: @client_id,
  client_secret: @client_secret,
  realm: nil,
  audience: nil,
  scope: 'openid'
)

  raise Auth0::InvalidParameter, 'Must supply a valid login_name' if .empty?
  raise Auth0::InvalidParameter, 'Must supply a valid password' if password.empty?

  request_params = {
    username: ,
    password: password,
    client_id: client_id,
    realm: realm,
    scope: scope,
    audience: audience,
    grant_type: realm ? 'http://auth0.com/oauth/grant-type/password-realm' : 'password'
  }

  populate_client_assertion_or_secret(request_params, client_id: client_id, client_secret: client_secret)

  ::Auth0::AccessToken.from_response request_with_retry(:post, '/oauth/token', request_params)
end