Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new login_ro method to replace login #133

Merged
merged 3 commits into from
Oct 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions lib/auth0/api/authentication_endpoints.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,47 @@ def obtain_user_tokens(code, redirect_uri, connection = 'facebook', scope = 'ope
end

# Get access and ID tokens using Resource Owner Password.
# Requires that your tenant has a Default Audience or Default Directory.
# @see https://auth0.com/docs/api/authentication#resource-owner-password
# @param login_name [string] Email or username for the connection
# @param password [string] Password
# @param client_id [string] Client ID from Application settings
# @param client_secret [string] Client Secret from Application settings
# @param realm [string] Specific realm to authenticate against
# @param audience [string] API audience
# @param scope [string] Scope(s) requested
# - Include an audience (above) for API access scopes
# - Use the default "openid" for userinfo calls
# @return [json] Returns the access_token and id_token
def login_with_resource_owner(
login_name,
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 login_name.empty?
raise Auth0::InvalidParameter,
'Must supply a valid password' if password.empty?
request_params = {
username: login_name,
password: password,
client_id: client_id,
client_secret: client_secret,
realm: realm,
scope: scope,
audience: audience,
grant_type: realm ? 'http://auth0.com/oauth/grant-type/password-realm' : 'password'
}
response = post('/oauth/token', request_params)
AccessToken.from_response post('/oauth/token', request_params)
end

# Get access and ID tokens using Resource Owner Password.
# TODO: Deprecate, use the login_with_resource_owner method in this module instead.
# @see https://auth0.com/docs/api/authentication#resource-owner-password
# @param username [string] Username or email
# @param password [string] Password
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading