2016-12-19 5 views
0

코드를 얻었습니다 : 4/sfPsZXlH-eO4kqj8EE8WDO70jEMn3HyMuk7ZvjkqL-Q#.Invalid_request OAuth2 Google?

object(stdClass)#1 (1) { 
    ["error"]=> 
    string(15) "invalid_request" 
} 

가 어떻게 무엇이 잘못 감지 할 수 있습니다 : 시도 후

토큰 액세스 URL을 요청하고 얻을 수 있습니다 :

$authUrl = "https://accounts.google.com/o/oauth2/token"; 

curl_setopt_array($curl, array(
    CURLOPT_POST => true, 
    CURLOPT_POSTFIELDS => array(
     'code' => $code, 
     'client_id' => CLIENT_ID, 
     'client_secret' => CLIENT_SECRET, 
     'redirect_uri' => getRedirectUri(), 
     'grant_type' => 'authorization_code' 
    ), 
    CURLOPT_URL => $authUrl, 
    CURLOPT_SSL_VERIFYPEER => false, 
    CURLOPT_RETURNTRANSFER => true 
)); 

을하지만 오류가?

+0

CURLOPT_POSTFIELDS의 출력을 표시 할 수 있습니까? 모두 같은 줄에 있어야하며 &는 HTML로 인코딩되지 않습니다. – DaImTo

+0

어떻게해야합니까? – Gagama

+0

나는'https : // github.com/google/google-api-php-client' 라이브러리를 사용하려하지만,'$ client-> setDeveloperKey ("YOUR_APP_KEY"); 공개 api 키인 프로젝트를 만들 때 Google 개발자 콘솔의 – Gagama

답변

0

위의 요청을 인쇄 해보세요.하지만 액세스 토큰을받는 토큰 URL로 AuthCode가 전달되는 것을 볼 수 없습니다. 위의 과정을 Google oauth 놀이터에서도 확인할 수 있습니다. https://developers.google.com/oauthplayground/