| @@ 201-212 (lines=12) @@ | ||
| 198 | * @inheritdoc |
|
| 199 | * @throws AuthenticationException - When Login request fails |
|
| 200 | */ |
|
| 201 | public function login() { |
|
| 202 | $EP = new OAuth2Token($this->apiURL); |
|
| 203 | $response = $EP->execute($this->credentials)->getResponse(); |
|
| 204 | if ($response->getStatus()=='200'){ |
|
| 205 | $this->setToken($response->getBody(FALSE)); |
|
| 206 | static::storeToken($this->token,$this->credentials['client_id']); |
|
| 207 | } else { |
|
| 208 | $error = $response->getBody(); |
|
| 209 | throw new AuthenticationException("Login Response [".$error['error']."] ".$error['error_message']); |
|
| 210 | } |
|
| 211 | return $this; |
|
| 212 | } |
|
| 213 | ||
| 214 | /** |
|
| 215 | * @inheritdoc |
|
| @@ 240-253 (lines=14) @@ | ||
| 237 | * @inheritdoc |
|
| 238 | * @throws AuthenticationException - When logout request fails |
|
| 239 | */ |
|
| 240 | public function logout(){ |
|
| 241 | if ($this->authenticated()){ |
|
| 242 | $EP = new OAuth2Logout($this->apiURL); |
|
| 243 | $response = $EP->execute()->getResponse(); |
|
| 244 | if ($response->getStatus()=='200'){ |
|
| 245 | unset($this->token); |
|
| 246 | static::removeStoredToken($this->credentials['client_id']); |
|
| 247 | }else{ |
|
| 248 | $error = $response->getBody(); |
|
| 249 | throw new AuthenticationException("Logout Response [".$error['error']."] ".$error['message']); |
|
| 250 | } |
|
| 251 | } |
|
| 252 | return $this; |
|
| 253 | } |
|
| 254 | ||
| 255 | /** |
|
| 256 | * @inheritdoc |
|