Closed jossydeleon closed 7 years ago
Is your password hashed?
Yes is hashed
Also, make sure you have grant_type
password and you are also using correct client_secret
. if you don't have client_secret make sure to run this command: php artisan passport:install
I am using grant_type = password
and client_id = 2 with its correct cliente secrect generated
try using client_id = 1 and it's correct client_secret
When I used client_id = 1 we got this:
{ "error": "invalid_client", "message": "Client authentication failed" }
make sure you have client_id =1 in oauth_clients
table
This is what we have in oauth_clients:
mysql> select * from oauth_clients; +----+---------+-------------------------+------------------------------------------+------------------+------------------------+-----------------+---------+---------------------+---------------------+ | id | user_id | name | secret | redirect | personal_access_client | password_client | revoked | created_at | updated_at | +----+---------+-------------------------+------------------------------------------+------------------+------------------------+-----------------+---------+---------------------+---------------------+ | 1 | NULL | Personal Access Client | EsmawsokHjfy5eTBqVPE86Moqg13JxWzONC75vsk | http://localhost | 1 | 0 | 0 | 2017-07-25 16:26:27 | 2017-07-25 16:26:27 | | 2 | NULL | Password Grant Client | tATASGXt5FiJWSJWXqp5jBvSAo7BP0VO2VaFPpzm | http://localhost | 0 | 1 | 0 | 2017-07-25 16:26:27 | 2017-07-25 16:26:27 |
so, you should use client_id 2 for password grant. another catch, even though we are using username
when we are creating access_token it's actually email
field in users table. so, make sure you have that email address.
Did it work?
We were using the email as username, but still is not working
Then, make sure your password is properly hashed.
Can I use this API to login user from an Android app?
@limaho yes.
@hasib32 now is working, was my bad. I had a blank space in password. Thanks. Now I am doing some test. Thanks again
I am running your tutorial, but I could not get the accessToken. This is the response that I received. I am trying with severals of emails registered in the database (fake data) with the password: test-password but i am getting this response
{ "error": "invalid_credentials", "message": "The user credentials were incorrect." }