danyal14's avatar

LumenPassport

Hi Guys,

I am using LumenPassport package, APIs are working fine in local docker environment.

API is deployed in AWS ECS, when hitting login endpoint it throws following error.

Any Idea, what is happening.

Client error: POST http://localhost/oauth/token/ resulted in a 405 Method Not Allowed

 public function login(Request $request){

        $http = new \GuzzleHttp\Client;

        try {
            $response = $http->post(config('services.passport.login_endpoint'), [
                'form_params' => [
                    'grant_type' => 'password',
                    'client_id' => config('services.passport.client_id'),
                    'client_secret' => config('services.passport.client_secret'),
                    'username' => $request->username,
                    'password' => $request->password,
                ],
            ]);
            $body = json_decode((string) $response->getBody(), true);
            return response()->json($body);

        } catch (\Exception $e) {
            if ($e->getCode() == 401) {
                return response()->json([
                    'status' => 'fail',
                    'message' => 'Unauthenticated'
                ], $e->getCode());
            }

            return response()->json([
                'status' => 'fail',
                'message' => 'Unauthenticated',
                'exception' => $e->getMessage()
            ], 400);

        }
    }
0 likes
0 replies

Please or to participate in this conversation.