lumen-api-oauth icon indicating copy to clipboard operation
lumen-api-oauth copied to clipboard

null from $response @ Proxy.php

Open janareit opened this issue 9 years ago • 15 comments

Any idea why I get null to my $response at Proxy.php?

ErrorException in Proxy.php line 46:
First parameter must either be an object or the name of an existing class
in Proxy.php line 46
at Application->Laravel\Lumen\{closure}('2', 'First parameter must either be an object or the name of an existing class', '/Volumes/E/Sites/sso/app/Auth/Proxy.php', '46', array('grantType' => 'password', 'data' => array('client_id' => '1', 'client_secret' => 'gKYG75sw', 'grant_type' => 'password', 'username' => '[email protected]', 'password' => '1234'), 'config' => object(Repository), 'client' => object(Client), 'guzzleResponse' => object(Response), 'response' => null))
at property_exists(null, 'access_token') in Proxy.php line 46
at Proxy->proxy('password', array('username' => '[email protected]', 'password' => '1234')) in Proxy.php line 11
at Proxy->attemptLogin(array('username' => '[email protected]', 'password' => '1234')) in routes.php line 20
at Closure->{closure}()
at call_user_func_array(object(Closure), array()) in Container.php line 502
at Container->call(object(Closure), array()) in Application.php line 1263
at Application->callActionOnArrayBasedRoute(array(true, array(object(Closure)), array())) in Application.php line 1237
at Application->handleFoundRoute(array(true, array(object(Closure)), array())) in Application.php line 1158
at Application->Laravel\Lumen\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in OAuthExceptionHandlerMiddleware.php line 19
at OAuthExceptionHandlerMiddleware->handle(object(Request), object(Closure))
at call_user_func_array(array(object(OAuthExceptionHandlerMiddleware), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Application.php line 1387
at Application->sendThroughPipeline(array('LucaDegasperi\OAuth2Server\Middleware\OAuthExceptionHandlerMiddleware', 'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse'), object(Closure)) in Application.php line 1164
at Application->dispatch(null) in Application.php line 1104
at Application->run() in index.php line 28

janareit avatar Aug 27 '15 09:08 janareit

Guzzle may have thrown a \GuzzleHttp\Exception\BadResponseException Can you check if this is the case and provide further details?

It may have been because you didn't modify config\app.php to include your url. Have you installed memcached or specified not to use memcached in your .env file? https://github.com/esbenp/lumen-api-oauth/issues/13 Have you added AUTH_MODEL=App\Auth\User to your .env file? https://github.com/esbenp/lumen-api-oauth/issues/9

Martyn10 avatar Aug 30 '15 05:08 Martyn10

I have faced the same problem. checked url in config\app.php. memcached is installed. AUTH_MODEL=App\Auth\user is specified.

Still having same problem.

rahulrockers avatar Sep 21 '15 15:09 rahulrockers

Okay I have resolved the above error by adding port number to my url in config/app.php , e.g. http://192.0.0.0:8000 then in .env file I changed SESSION_DRIVER=cookie but now when I click on login button and checked in console, it is just loading, nothing happens. and when I hit http://192.0.0.0:8000/oauth/access-token with username, password, client_id, client_secret and grant_type through postman then it is giving response as - Array ( [access_token] => 6TxUnhoXF659fku3t6D2CRM3XewOmXup6xbAUBBz [token_type] => Bearer [expires_in] => 10 [refresh_token] => BLQqBTaTn8s6jq9yjepRGFWOGvP882LqzMEYf4Sa )

can you please help?

prashantidealittechno avatar Sep 30 '15 08:09 prashantidealittechno

@rahulrockers - please try SESSION_DRIVER=cookie in your .env file and update composer, It works for me, Thank you @esbenp :)

prashantidealittechno avatar Sep 30 '15 09:09 prashantidealittechno

Everything is setup but the last annoying one is that I am not able to test it- when I click on login button it generates access token but when I am going to test it via postman like this - http://wikilocal.mysite.com/index.php/api/resource method - GET headers - Authorization: Bearer XuuHS7kixLIwIpHI9iSIaoMMN84CgoiY1iNR9GvD

I have tried this also - access_token: Bearer XuuHS7kixLIwIpHI9iSIaoMMN84CgoiY1iNR9GvD

it is giving following response - {"error":"invalid_request","error_description":"The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "access token" parameter."}

please help.

prashantidealittechno avatar Sep 30 '15 10:09 prashantidealittechno

@prashantidealittechno , You could give it a try at postman:

Method - GET URL - http://wikilocal.mysite.com/index.php/api/resource Parameters access_token: XuuHS7kixLIwIpHI9iSIaoMMN84CgoiY1iNR9GvD

OR

Use curl like below(for header case):

curl http://wikilocal.mysite.com/index.php/api/resource  -X GET  -d ' {"user_name": 'whatever'}' -H  "Content-type: application/json"  -H  'Authorization: Bearer token="XuuHS7kixLIwIpHI9iSIaoMMN84CgoiY1iNR9GvD"'

or

curl http://wikilocal.mysite.com/index.php/api/resource  -X GET  -d ' {"user_name": 'whatever'}' -H  "Content-type: application/json"  -H  'Authorization: Bearer access_token="XuuHS7kixLIwIpHI9iSIaoMMN84CgoiY1iNR9GvD"'

or

curl http://wikilocal.mysite.com/index.php/api/resource  -X GET  -d ' {"access_token": 'XuuHS7kixLIwIpHI9iSIaoMMN84CgoiY1iNR9GvD'}' -H  "Content-type: application/json"  -H  'Authorization: Bearer token="XuuHS7kixLIwIpHI9iSIaoMMN84CgoiY1iNR9GvD"'

depending on your server request created.

Good Luck!

manish-shrivastava avatar Sep 30 '15 12:09 manish-shrivastava

@prashantidealittechno try once like below: auth-api-test-5

manish-shrivastava avatar Sep 30 '15 12:09 manish-shrivastava

@manish-shrivastava I have tried everything, still not working may be I changed SESSION_DRIVER=cookie instead of memcached

prashantidealittechno avatar Sep 30 '15 12:09 prashantidealittechno

@manish-shrivastava on every request it is giving - { "error": "invalid_request", "error_description": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "access token" parameter." }

prashantidealittechno avatar Sep 30 '15 12:09 prashantidealittechno

when try with this - http://wikilocal.mysite.com/index.php/api/test?access_token=0WYfs9WsX6W0A8Edzsaehrfls2AkyFE87YrMUkgU

it gives following response - { error: "access_denied" error_description: "The resource owner or authorization server denied the request." }

prashantidealittechno avatar Sep 30 '15 13:09 prashantidealittechno

@prashantidealittechno But why it's not working with memcache? Or is there a issue with localhost? Shall I try with live website? I have also posted question on stackoverflow but didn't get answer yet.

And My localhost url is like http://localhost/lumen/lumen/public/ No port number.

rahulrockers avatar Sep 30 '15 13:09 rahulrockers

@rahulrockers you may check phpinfo(), whether memchached is installed on your system or not, remember there is a difference between memcache and memcached. if not then you can try oauth2 after installing memcached.

sachinvrg avatar Sep 30 '15 17:09 sachinvrg

finally I have found out my issue, it is due to incorrect expiration time, I can test it properly with http://wikilocal.mysite.com/index.php/api/test?access_token=0WYfs9WsX6W0A8Edzsaehrfls2AkyFE87YrMUkgU this URL after make correction in expire_time Thank you.

prashantidealittechno avatar Oct 01 '15 05:10 prashantidealittechno

@sachinvrg yes, you are right. memcache is installed on my system not memcached. Could you provide me a link or anything to install memcached on windows? Because I found some of stuffs related to memcache.

rahulrockers avatar Oct 02 '15 08:10 rahulrockers

I just pulled the repository and tried my self. I got the error because the app url in https://github.com/esbenp/lumen-api-oauth/blob/master/config/app.php was not correct.

esbenp avatar Oct 17 '15 07:10 esbenp