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