Ejemplo n.º 1
0
 /**
  * Grabs the 1st stage code from the request object
  *
  * @return string/null
  * @throws Exception\OAuth2Exception
  */
 public function getCodeFromRequest()
 {
     $query = $this->request->query();
     if ($query->offsetExists($this->options->stage1Response->error->accessKey)) {
         throw new OAuth2Exception('Error gaining authorisation: ' . $query->get($this->options->stage1Response->error->accessKey));
     }
     if ($query->offsetExists($this->options->stage1Response->code->accessKey)) {
         if ($query->get($this->options->stage1Response->state->accessKey) !== $this->session->state) {
             throw new OAuth2Exception('Error gaining authorisation: state mismatch');
         }
         return $query->get($this->options->stage1Response->code->accessKey);
     }
     return null;
 }