msslgomez
4 weeks ago
241
17
General

GET method is not supported for this route. Supported methods: POST.

Posted 4 weeks ago by msslgomez

I'm using a post request, this is the code

//API routes
Route::post('getToken', '[email protected]');

//getToken Method
        $client = new Client();
        $params = [
//            'client_id' => env('4GEEKS_CLIENT_ID'),
//            'client_secret' => env('4GEEKS_CLIENT_SECRET'),
        ];

        $headers = [
            'grant_type' => 'client_credentials',
            'client_id' => env('4GEEKS_CLIENT_ID'),
            'client_secret' => env('4GEEKS_CLIENT_SECRET'),
        ]; 

        $response = $client->request('POST', 'https://api.payments.4geeks.io/authentication/token', [
            'json' => $params,
            'headers' => $headers
        ]);

        return $response->getBody();

I'm using Guzzle to try and use this 4Geeks payment api (http://docs.payments.4geeks.io/?javascript#authentication) that's the link in case you want to check it out, it's in Spanish. It's really vague I'll give a brief translation on the authentication part

4Geeks Payments uses oAuth2 so be sure to send grant_type=client_credentials. Also you must send client_id=<4geeks-payments-client-id>, client_secret=<4geeks-payments-client-secret>. This will return an access_token, which will need to be sent in every other request going forware. Remember to never have these credentials visible to anyone, never upload them to repositories like GitHub and never share them. It's recommended to use these credential in environment variables.

I'm not sure where to send the grant_type, client_id, and client_secret, in the headers or params.

I did try running composer dumpautoload and php artisan route:cache but I'm still getting that error. What can I do to fix it?

Please sign in or create an account to participate in this conversation.