Update scopes for calendar API, remove unnecessary logging
This commit is contained in:
@@ -21,7 +21,6 @@ class OAuth extends FormWidgetBase {
|
||||
$this->vars['redirectUrl'] = $client->getRedirectUri();
|
||||
$this->vars['isAccessTokenExpired'] = $client->isAccessTokenExpired() ? '1' : '0';
|
||||
$this->vars['clientIdExist'] = null != Settings::get('client_id', null) ? '1' : '0';
|
||||
$this->vars['accessToken'] = print_r(Settings::get('access_token'), true);
|
||||
|
||||
return $this->makePartial('oauth');
|
||||
}
|
||||
@@ -30,28 +29,34 @@ class OAuth extends FormWidgetBase {
|
||||
|
||||
$class = new GoogleCalendarClient(true);
|
||||
$client = $class->getClient();
|
||||
$client->setPrompt('consent');
|
||||
|
||||
if ($client->isAccessTokenExpired()) {
|
||||
// Request authorization from the user.
|
||||
$authUrl = $client->createAuthUrl();
|
||||
Log::info('G-Calendar: Request authorization with URL ['. $authUrl .'].');
|
||||
//Log::info('G-Calendar: Request authorization with URL ['. $authUrl .'].');
|
||||
|
||||
$this->vars['auth_url'] = $authUrl;
|
||||
|
||||
return $this->makePartial('gaccess');
|
||||
}
|
||||
|
||||
Log::info('G-Calendar: Access token not expired.');
|
||||
Flash::error(Lang::get('nicost.gcalendar::lang.message.accessTokenNotExpired'));
|
||||
Flash::info(Lang::get('nicost.gcalendar::lang.message.accessTokenNotExpired'));
|
||||
}
|
||||
|
||||
public function onClearAccessToken() {
|
||||
Settings::set('access_token', '');
|
||||
Settings::set('access_token', []);
|
||||
Flash::success(Lang::get('nicost.gcalendar::lang.message.accessTokenRemoved'));
|
||||
|
||||
$this->vars['isAccessTokenExpired'] = '1';
|
||||
return $this->refreshTokenStatus();
|
||||
}
|
||||
|
||||
private function refreshTokenStatus() {
|
||||
$class = new GoogleCalendarClient(true);
|
||||
$client = $class->getClient();
|
||||
|
||||
$this->vars['isAccessTokenExpired'] = $client->isAccessTokenExpired() ? '1' : '0';
|
||||
|
||||
return Redirect::refresh();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user