Configuring OAuth2 in Lumen

I followed this article written to set up OAuth2 for my API that I am writing to Lumen

. I finished setting up and I implemented the client to test that it works. I haven't been able to get it to work. When I click on the "Login to API" button, it sends a POST to http://myserver.com/login

and it never ends. It hangs here and I am not getting any exceptions or errors. Also, when it freezes, I can't just refresh the page. I have to serve it on a different port if that's the key to what's going on. I was outputting a bunch of log messages and I narrowed the problem down to this:

$guzzleResponse = $client->post(sprintf('%s/oauth/access-token', $config->get('app.url')), [
            'body' => $data
        ]);

      

I have checked the parameters and they look good. $client

is a client GuzzleHttp

. The post method inside looks like this:

public function post($url = null, array $options = [])
{
    return $this->send($this->createRequest('POST', $url, $options));
}

      

I think I might have to enable cookies in Lumen. Where will I go to find out? Does anyone have any other ideas?

+3


source to share


3 answers


To enable cookie, you can do this in the .env file -

SESSION_DRIVER=cookie

      



Then run the command composer update

.

+1


source


If you checked your .env? .. please add AUTH_MODEL = App \ Auth \ User if not.



0


source


Sometimes Guzzle doesn't work with a port, for example localhost: 8888. If you started your server on some port, change it to the default value of 80 and it will work.

0


source







All Articles