Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers\API\Auth;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
- use GuzzleHttp\Exception\GuzzleException;
- use GuzzleHttp\Client;
- class LoginController extends Controller
- {
- /**
- * Index Function.
- *
- * @return \Illuminate\Http\Response
- */
- public function index(Request $request)
- {
- $http = new Client;
- // Response send exception here for 401 bad request which makes this route 500 bad request
- $response = $http->post(url('oauth/token'), [
- 'form_params' => [
- 'grant_type' => 'password',
- 'client_id' => '2',
- 'client_secret' => 'XXXXXXXXX',
- 'username' => $request->post('username'),
- 'password' => $request->post('password'),
- 'scope' => '*',
- ],
- ]);
- // i dont get this response because the response sends exception before this
- return json_decode((string) $response->getBody(), true);
- }
- }
Add Comment
Please, Sign In to add comment