Я использую HWIO Bundle для google api, и когда у меня есть ответ от google refreshToken = null, почему? Как обновить токенGoogle api refresh_token null и как обновить токен доступа
oAuthToken = {HWI\Bundle\OAuthBundle\Security\Core\Authentication\Token\OAuthToken} [11]
accessToken = "ya29.Ci8lA1JTu9CB81dOFy-nzszViRgCI2CvvKVrCd0Lq-8I0QR_dIrl-_7RccdGt1Islg"
rawToken = {array} [4]
access_token = "ya29.Ci8lA1JTu9CB81dOFy-nzszViRgCI2CvvKVrCd0Lq-8I0QR_dIrl-_7RccdGt1Islg"
token_type = "Bearer"
expires_in = 3578
id_token = "xxxxx"
refreshToken = null
expiresIn = 3578
createdAt = 1468957368
tokenSecret = null
resourceOwnerName = null
, потому что в/apiclient "версии" Google: "1.1.7" в функции нужно refresh_token
public function getRefreshToken()
{
if (array_key_exists('refresh_token', $this->token)) {
return $this->token['refresh_token'];
} else {
return null;
}
}
это мой маркер доступа
{"access_token":"ya29.Ci8lA1JTu9CB81dOFy-nzszViRgCI2CvvKVrCd0Lq-8I0QR_dIrl-_7RccdGt1Islg","token_type":"Bearer","expires_in":3578,"id_token":"xxxx","created":1468957368}
не нужно обновлять токен, потому что из google get refreshToken = null или нужно установить значение null с токеном обновления ключа или этим донтом?
$isExpired = $client->isAccessTokenExpired(); // true (bool Returns True if the access_token is expired.)
$refresh = $client->getRefreshToken(); //null because not gahe refresh token
$client->getGoogleClient()->setAccessType ("offline"); //some recomendation
$client->getGoogleClient()->setApprovalPrompt ("force"); //some recomendation
$isAgainExpired = $client->isAccessTokenExpired(); // still true (expired)
еще исключение - The OAuth 2.0 access token has expired, and a refresh token is not available. Refresh tokens are not returned for responses that were auto-approved.
как обновить маркер и как с маркером получить токен обновления для обновления маркеров?
Стараюсь
- В моем коде слишком
$client = new Google_Client()
но в обертке, в конструкторе. я получить маркер доступа от HWIO пачке:
hwi_oauth: connect: account_connector: app.provider.user_provider firewall_name: secured_area resource_owners: google: type: google client_id: xxx.apps.googleusercontent.com client_secret: xxx scope: "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/drive"
и после того, как я получаю маркер доступа я поставил его в БД. Затем в Action я создаю оболочку для google api (новый Google Client()) и устанавливаю для этого клиента мой токен доступа из БД. Как обновить токен доступа? Я стараюсь в действии использование функции Google API Lib setAccessType и setApprovalPrompt, но не ЭФФЕКТ
public function __construct(array $config, LoggerInterface $symfonyLogger = null)
{
// True if objects should be returned by the service classes.
// False if associative arrays should be returned (default behavior).
$config['use_objects'] = true;
$client = new \Google_Client($config);
if ($symfonyLogger) {
//BC for Google API 1.0
if (class_exists('\Google_Logger_Psr')) {
$googleLogger = new \Google_Logger_Psr($client, $symfonyLogger);
$client->setLogger($googleLogger);
} else {
$client->setLogger($symfonyLogger);
}
}
$client -> setApplicationName($config['application_name']);
$client -> setClientId($config['oauth2_client_id']);
$client -> setClientSecret($config['oauth2_client_secret']);
$client -> setRedirectUri($config['oauth2_redirect_uri']);
$client -> setDeveloperKey($config['developer_key']);
$client -> setAccessType ($config['access_type']);
$client -> setApprovalPrompt ($config['approval_prompt']);
$this -> client = $client;
}
конфигурации это:
happy_r_google_api:
application_name: carbon-quanta-137312
oauth2_client_id: xxxx.apps.googleusercontent.com
oauth2_client_secret: xxx
oauth2_redirect_uri: null
developer_key: null
site_name: aog.local.com
access_type: offline
approval_prompt: force
и если в действии я устанавливаю на клиенте Google некоторые параметры, это же, если я добавить конструкторI, так что я делаю неправильно?
Я обновить мой вопрос, в моей компетенции трех параметров, и я в конструкторе обертке 'access_type: автономный approval_prompt: force' и до сих пор истек токенов обновления, как обновление или, может быть, проблема в пакете HWIO. Я получаю токен доступа от HWIO. Beacause У меня есть еще одна проблема с этой либой. Я загружаю файл на Google Drive, но имею файл emty и создаю функцию, но теперь теряю ее после восстановления проекта и установки композитора. Я думаю, что-то не так ( –