I've implemented authentication through auth0 on my laravel application, the login works fine and it returns a token and user details, here is the code for the login:
$auth0Response = $guzzle->post('myauthurl/token', [
'header' => [
"content-type"=>"application/x-www-form-urlencoded"
],
'form_params' => [
'grant_type'=> "password",
"username"=>trim($data["username"]),
"password"=>trim($data["password"]),
"client_id"=>"myclient_secret",
"client_secret"=>"secret",
"audience"=>"https://myurl.auth0.com/userinfo"
]
]);
$auth0ResponseBody = json_decode($auth0Response->getBody(),true);
$additionalDetails = $this->getUserDetails(trim($data["username"]));
$userDetails = array_merge($auth0ResponseBody,$additionalDetails);
but when I get the token from the response, pass it on my request headers and try to access a protected route, I get an error with message 'Wrong number of segments
{
"error": {
"message": "Wrong number of segments",
"statusCode": 401
}
}