Permalink
Browse files

🔒 Implement OAuth process

  • Loading branch information...
lorisleiva committed Aug 17, 2018
1 parent 433195f commit a9ba39b2ca6ad08f28ac7f55200e6657ab69033f
Showing with 25 additions and 1 deletion.
  1. +18 −1 app/Http/Controllers/GoogleAccountController.php
  2. +7 −0 app/Services/Google.php
@@ -29,7 +29,24 @@ public function index()
*/
public function store(Request $request, Google $google)
{
// TODO
if (! $request->has('code')) {
return redirect($google->createAuthUrl());
}
$google->authenticate($request->get('code'));
$account = $google->service('Plus')->people->get('me');
auth()->user()->googleAccounts()->updateOrCreate(
[
'google_id' => $account->id,
],
[
'name' => head($account->emails)->value,
'token' => $google->getAccessToken(),
]
);
return redirect()->route('google.index');
}
/**
View
@@ -18,6 +18,13 @@ function __construct()
$client->setIncludeGrantedScopes(config('services.google.include_granted_scopes'));
$this->client = $client;
}
public function connectUsing($token)
{
$this->client->setAccessToken($token);
return $this;
}
public function service($service)
{

0 comments on commit a9ba39b

Please sign in to comment.