oauth-4-laravel icon indicating copy to clipboard operation
oauth-4-laravel copied to clipboard

HTTP Code: HTTP/1.1 400 Bad Request

Open KamilCwiertnia opened this issue 5 years ago • 0 comments

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

KamilCwiertnia avatar Nov 29 '19 13:11 KamilCwiertnia