3
refresh_token에 문제가 있습니다. 나는 그것을 전혀 얻지 못한다. 나는이 refresh_token이 반환되지 않은 후에 로그인 한 후에 만이 토큰을 얻는다는 것을 읽었습니다. 첫 번째 방법은 초기화 GAPI입니다 :google api - no refresh_token
initGp: function() {
requirejs(['google'],
function (gapi) {
gapi.load('auth2', function() {
this.auth2 = gapi.auth2.init({
client_id: 'client_id',
scope: 'https://www.googleapis.com/auth/youtube.readonly https://www.googleapis.com/auth/youtube.upload https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'
});
}.bind(this));
}.bind(this));
},
버튼을 사용자가 클릭 응답 코드에 보낼 수있다 "YouTube에 연결"때 옆에 '/ 연결-구글에서'경로 : PHP I에서 다음
connectGp: function() {
var self = this;
this.auth2.grantOfflineAccess({'redirect_uri': 'postmessage'}).then(
function(response) {
$('.gp-button').addClass('loading');
var vars = {
code: response.code
};
$.ajax({
url: myUrl+"/connect-google",
data: vars,
type: "GET",
success: function(response) {
window.location.reload();
}
});
});
},
' 도착 :
$googleClient = new \Google_Client();
$googleClient->setClientId($client_id);
$googleClient->setClientSecret($client_secret);
$googleClient->setRedirectUri('postmessage');
$googleClient->setAccessType("offline");
$googleClient->setScopes($scopes);
$token = $googleClient->authenticate($code);
$access_token = $googleClient->getAccessToken();
var_dump($access_token);
하지만 access_token에서 refresh_token을받지 못했습니다. 왜 ? 그것은 'postmessage'를 사용하고있어 beacuse입니까?
이 기능을 현재 새 라이브러리로 대체 한 기능을 알고 계십니까? – cevizmx