/**
  * This method is called when a user clicks on a "Request Permission from Google" link.
  * This link will create a remote API call for Google and redirect the user from WordPress to Google.
  * Google will redirect back to WordPress after the user responds.
  */
 public function handleOAuthPermissionRequestAction()
 {
     $this->logger->debug('handling OAuth Permission request');
     $authenticationManager = PostmanAuthenticationManagerFactory::getInstance()->createAuthenticationManager(PostmanTransportRegistry::getInstance()->getCurrentTransport(), $this->options, $this->authorizationToken);
     $transactionId = $authenticationManager->generateRequestTransactionId();
     PostmanSession::getInstance()->setOauthInProgress($transactionId);
     $authenticationManager->requestVerificationCode($transactionId);
 }
Example #2
0
 /**
  */
 private function ensureAuthtokenIsUpdated(PostmanModuleTransport $transport, PostmanOptions $options, PostmanOAuthToken $authorizationToken)
 {
     assert(!empty($transport));
     assert(!empty($options));
     assert(!empty($authorizationToken));
     // ensure the token is up-to-date
     $this->logger->debug('Ensuring Access Token is up-to-date');
     // interact with the Authentication Manager
     $wpMailAuthManager = PostmanAuthenticationManagerFactory::getInstance()->createAuthenticationManager();
     if ($wpMailAuthManager->isAccessTokenExpired()) {
         $this->logger->debug('Access Token has expired, attempting refresh');
         $wpMailAuthManager->refreshToken();
         $authorizationToken->save();
     }
 }