adamlundrigan / LdcZfcUserOAuth2

An extension for zf-oauth2 allowing use of ZfcUser as authentication source
BSD 3-Clause "New" or "Revised" License
11 stars 9 forks source link

Cannot authenticate user from ZFC user table #3

Open DevDev1 opened 9 years ago

DevDev1 commented 9 years ago

Hi, just trying your module and have few quesions.

I set up Apigility, and oAuth2. I can make POST to /oauth

{"grant_type":"password", "username":"testuser", "client_id":"testclient2", "password":"testpass" }

('testuser' is stored in oauth tables - oauth_users) and got response:

{"access_token":"e59610ddeab7dd559bcea5e25e46092c7d8f25b1","expires_in":3600,"token_type":"Bearer","scope":null,"refresh_token":"10e6a1769bd133bb766bd87fdea5d86e51d4af1a"}

I believe oauth as is - is working. I installed zfc user tested /user/login (sing up, login, logout - everything works)

Now I installed LdcZfcUserOAuth2 module, config it by instruction

'zf-oauth2' => array( 'storage' => 'ldc-zfc-user-oauth2-storage-pdo', 'db' => array( 'dsn' => 'mysql:dbname=mydevtest;host=localhost', 'username' => 'mydevtest', 'password' => 'pass',
),

in this step I must add also 'db' because without it I got error "...configuration ['zf-oauth2']['db'] for OAuth2 is missing..."

'auth_adapters' => array( 100 => 'ldc-zfc-user-oauth2-authentication-adapter-db' ),

After that I test POST to /oauth with user/pass combination from ZFCUser (user) table (created in step when testing ZFCUser's /user/login): {"grant_type":"password", "username":"user@test.com", "client_id":"testclient2", "password":"password"}

and response is:

{"type":"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html","title":"invalid_grant","status":401,"detail":"Invalid username and password combination"}

If i try user/pass from oauth table it works. It seems that it does NOT look for user/pass from ZFC user table.. Any idea/hint how to solve this?

Thnx

adamlundrigan commented 9 years ago

I'm not sure off-hand what could cause this. There have been updates to zf-oauth2 and ZfcUser since I wrote and last used this module so something may have changed. When I get a chance I'll try setting up a new project myself and see if I can reproduce the issue you're having.

DevDev1 commented 9 years ago

Hi there, I think I got it. It work - What was wrong is setting up oauth2 via Apigility admin interface - it create adapter, and I believe that was wrong. Now I set up everything manualy and it work. I can't see oauth in apigility admin and it break /user/login (with correct u/p combination it redirect to /login again and not to wellcome page), but it work - I can auth user from zfc-user table

I can share skeleton project later so you can put in as an example if you want.

Thank you for your time.

johnsonmartin commented 8 years ago

i run this: http://127.0.0.19:8888/oauth

added below json in body row data: { "grant_type": "password", "username": "testuser", "password": "testpass", "client_id": "testclient", "client_secret": "testpass" }

I am getting this error :

{ "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html", "title": "invalid_grant", "status": 401, "detail": "Invalid username and password combination" }

how to remove the issue, please tell me Thank you