Advertisement
Guest User

Untitled

a guest
May 18th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. public function authToken (Request $request) {
  2.     $username = $request->input('username');
  3.     $password = $request->input('password');
  4.  
  5.     if (Auth::attempt(['email' => $username, 'password' => $password])) {
  6.         $http = new \GuzzleHttp\Client();
  7.         $response = $http->post('http://localhost:8000/oauth/token', [
  8.             'form_params' => [
  9.                 'grant_type' => 'password',
  10.                 'client_id' => '2',
  11.                 'client_secret' => 'pc4cjW6KEwufFAf31f1HRFFTtL2dOHPmTgDLKR',
  12.                 'username' => $username,
  13.                 'password' => $password,
  14.                 'scope' => '',
  15.             ],
  16.         ]);
  17.         return json_decode((string) $response->getBody(), true);
  18.     } else {
  19.         return 'Email or Password is incorrect';
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement