Advertisement
Guest User

Untitled

a guest
May 18th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 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.     // Auth accepted > send to /oauth/token
  7.     $http = new \GuzzleHttp\Client();
  8.  
  9.     $response = $http->post('http://localhost:8000/test', [
  10.         'form_params' => [
  11.             'grant_type' => 'password',
  12.             'client_id' => '2',
  13.             'client_secret' => 'pc4cjW6KEwufFAf31f1HRFFTtL2dOHPmTgDLKR',
  14.             'username' => $username,
  15.             'password' => $password,
  16.             'scope' => '',
  17.         ],
  18.     ]);
  19.  
  20.     return json_decode((string) $response->getBody(), true);
  21.  
  22.     } else {
  23.         return 'Email or Password is incorrect';
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement