Skip to content

Commit b579a7d

Browse files
author
David Jaress
committed
Update /login to use the current api
1 parent b91f0f2 commit b579a7d

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

lib/auth0/api/authentication_endpoints.rb

+10-9
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,17 @@ def login(username, password, id_token = nil, connection_name = UP_AUTH, options
5757
raise Auth0::InvalidParameter, 'Must supply a valid username' if username.to_s.empty?
5858
raise Auth0::InvalidParameter, 'Must supply a valid password' if password.to_s.empty?
5959
request_params = {
60-
client_id: @client_id,
61-
username: username,
62-
password: password,
63-
scope: options.fetch(:scope, 'openid'),
64-
connection: connection_name,
65-
grant_type: options.fetch(:grant_type, password),
66-
id_token: id_token,
67-
device: options.fetch(:device, nil)
60+
client_id: @client_id,
61+
client_secret: @client_secret,
62+
username: username,
63+
password: password,
64+
scope: options.fetch(:scope, 'openid'),
65+
connection: connection_name,
66+
grant_type: options.fetch(:grant_type, password),
67+
id_token: id_token,
68+
device: options.fetch(:device, nil)
6869
}
69-
post('/oauth/ro', request_params)
70+
post('/oauth/token', request_params)
7071
end
7172

7273
# Signup using username/password

spec/lib/auth0/api/authentication_endpoints_spec.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@
5757

5858
context '.login' do
5959
it { expect(@instance).to respond_to(:login) }
60-
it 'is expected to make post to /oauth/ro' do
60+
it 'is expected to make post to /oauth/token' do
6161
expect(@instance).to receive(:post).with(
62-
'/oauth/ro',
63-
client_id: @instance.client_id, username: '[email protected]',
62+
'/oauth/token',
63+
client_id: @instance.client_id,
64+
username: '[email protected]',
65+
client_secret: @instance.client_secret,
6466
password: 'password', scope: 'openid', connection: 'Username-Password-Authentication',
6567
grant_type: 'password', id_token: nil, device: nil
6668
)

spec/support/dummy_class.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class DummyClass
2-
attr_reader :domain, :client_id
2+
attr_reader :domain, :client_id, :client_secret
33

44
def initialize
55
@domain = 'test.auth0.com'

0 commit comments

Comments
 (0)