public static function logout(UserAuthTicket $authTicket)
 {
     try {
         $authentication = AppAuthenticator::getInstance();
         //var_dump($authTicket);
         $resourceUrl = static::getLogoutUrl($authTicket);
         $client = new Client(['base_uri' => MozuConfig::$baseAppAuthUrl, 'verify' => false]);
         $headers = ["content-type" => "application/json", Headers::X_VOL_APP_CLAIMS => $authentication->getAppClaim()];
         var_dump($headers);
         $promise = $client->requestAsync("DELETE", $resourceUrl, ['headers' => $headers, 'exceptions' => true]);
         $promise->wait();
     } catch (\Exception $e) {
         HttpHelper::checkError($e);
     }
 }
示例#2
0
 private function refreshAuthTicket()
 {
     try {
         $requestData = new AuthTicketRequest();
         $requestData->refreshToken = $this->authTicket->refreshToken;
         $client = new Client(['base_uri' => MozuConfig::$baseAppAuthUrl, 'verify' => false]);
         $headers = ["content-type" => "application/json"];
         $body = json_encode($requestData);
         $promise = $client->requestAsync("PUT", AuthTicketUrl::RefreshAppAuthTicketUrl(null)->getUrl(), ['headers' => $headers, 'body' => $body, 'exceptions' => true]);
         $response = $promise->wait();
         $jsonResp = $response->getBody(true);
         $this->authTicket = json_decode($jsonResp);
         $this->setRefreshInterval(true);
     } catch (\Exception $e) {
         HttpHelper::checkError($e);
     }
 }
 public static function authenticate(CustomerUserAuthInfo $customerAuthInfo, $tenantId, $siteId)
 {
     try {
         $authentication = AppAuthenticator::getInstance();
         $resourceUrl = CustomerAuthTicketUrl::createUserAuthTicketUrl(null);
         $client = new Client(['base_uri' => static::getAuthUrl($tenantId), 'verify' => false]);
         $headers = ["content-type" => "application/json", Headers::X_VOL_APP_CLAIMS => $authentication->getAppClaim(), Headers::X_VOL_SITE => $siteId];
         $body = json_encode($customerAuthInfo);
         $promise = $client->requestAsync($resourceUrl->getVerb(), $resourceUrl->getUrl(), ['headers' => $headers, 'body' => $body, 'exceptions' => true]);
         $response = $promise->wait();
         $jsonResp = $response->getBody(true);
         $authResponse = json_decode($jsonResp);
         $authProfile = static::setUserAuth($authResponse, $tenantId, $siteId);
         return $authProfile;
     } catch (\Exception $e) {
         HttpHelper::checkError($e);
     }
 }