oauth-4-laravel
oauth-4-laravel copied to clipboard
HTTP Code: HTTP/1.1 400 Bad Request
I have a problem
My code: ` public function importGmail() {
$code = Request::get('code');
$googleService = \OAuth::consumer('Google');
if(!is_null($code)) {
$token = $googleService->requestAccessToken($code);
$result = json_decode($googleService->request('https://www.google.com/m8/feeds/contacts/default/full?alt=json&max-results=400'), true);
$emails = []; // initialize the new array
foreach ($result['feed']['entry'] as $contact) {
if (isset($contact['gd$email'])) { // Sometimes, a contact doesn't have email address
$emails[] = $contact['gd$email'][0]['address'];
}
}
return $emails;
}
else {
$url = $googleService->getAuthorizationUri();
return redirect((string)$url);
}
}`
Function return: HTTP Code: HTTP/1.1 400 Bad Request