mercredi 30 août 2017

API call returns on postman, but returns a 500 internal server error when called and logged in browser

This is related to Laravel 5.4 and its Passport Password Grant.

I have routes for obtaining an access_token for the user to use that works completely fine.

I also have a route to refresh the token should the current access token expire.

When I use Postman to hit the route

http://ift.tt/2x3PnEF

I get this back which is valid:

"data": {
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOi...deleting most of it.",
    "expires_in": 600
}

However when I hit the route from the browser, using axios via this code:

let  headers = { 'Content-type': 'application/json' }
return axios.post("http://ift.tt/2x3PnEF", {headers: headers}).then(res => {
    if (res) return res;
        }).catch(err => {
            if (err) return err.response;
        });

I get an HTTP 500 Error status code.

I'm tailing the laravel log for errors as well and this is the stack trace.

[2017-08-30 07:21:41] local.ERROR: GuzzleHttp\Exception\ClientException: Client error: POST http://ift.tt/2vDGzBN resulted in a 400 Bad Request response: {"error":"invalid_request","message":"The request is missing a required parameter, includes an invalid parameter value, (truncated...) in /home/vagrant/Code/work/vendorgraphs-api/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113

The other part of this error is that it may be a malformed value.

Doesn't make sense to me and I've tried everything from making curl requests directly from PHP code and also used http_query_builder functionality.

Cache-Control →no-cache, private
Connection →keep-alive
Content-Type →application/json

This is what's set on Postman with the request. I am sending those headers from the browser as well. Any ideas on what might be causing the issue? This is driving me crazy.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iHhZy0
via IFTTT

Aucun commentaire:

Enregistrer un commentaire