| @@ 193-204 (lines=12) @@ | ||
| 190 | * @inheritdoc |
|
| 191 | * @throws AuthenticationException - When Login request fails |
|
| 192 | */ |
|
| 193 | public function login() { |
|
| 194 | $EP = new OAuth2Token($this->apiURL); |
|
| 195 | $response = $EP->execute($this->credentials)->getResponse(); |
|
| 196 | if ($response->getStatus()=='200'){ |
|
| 197 | $this->setToken($response->getBody(false)); |
|
| 198 | static::storeToken($this->token,$this->credentials['client_id']); |
|
| 199 | } else { |
|
| 200 | $error = $response->getBody(); |
|
| 201 | throw new AuthenticationException("Login Response [".$error['error']."] ".$error['error_message']); |
|
| 202 | } |
|
| 203 | return $this; |
|
| 204 | } |
|
| 205 | ||
| 206 | /** |
|
| 207 | * @inheritdoc |
|
| @@ 232-245 (lines=14) @@ | ||
| 229 | * @inheritdoc |
|
| 230 | * @throws AuthenticationException - When logout request fails |
|
| 231 | */ |
|
| 232 | public function logout(){ |
|
| 233 | if ($this->authenticated()){ |
|
| 234 | $EP = new OAuth2Logout($this->apiURL); |
|
| 235 | $response = $EP->execute()->getResponse(); |
|
| 236 | if ($response->getStatus()=='200'){ |
|
| 237 | unset($this->token); |
|
| 238 | static::removeStoredToken($this->credentials['client_id']); |
|
| 239 | }else{ |
|
| 240 | $error = $response->getBody(); |
|
| 241 | throw new AuthenticationException("Logout Response [".$error['error']."] ".$error['message']); |
|
| 242 | } |
|
| 243 | } |
|
| 244 | return $this; |
|
| 245 | } |
|
| 246 | ||
| 247 | /** |
|
| 248 | * @inheritdoc |
|