AmazonOAuth2Client::authenticate PHP Метод

authenticate() публичный Метод

public authenticate ( $code )
    public function authenticate($code)
    {
        $params = array("client_id" => $this->client_id, "client_secret" => $this->client_secret, "grant_type" => 'authorization_code', "redirect_uri" => $this->redirect_uri, "code" => $code);
        $response = $this->request($this->token_url, http_build_query($params), $this->curl_authenticate_method);
        $response = $this->parseRequestResult($response);
        if (!$response || !isset($response->access_token)) {
            throw new Exception("The Authorization Service has return: " . $response->error);
        }
        if (isset($response->access_token)) {
            $this->access_token = $response->access_token;
        }
        if (isset($response->refresh_token)) {
            $this->refresh_token = $response->refresh_token;
        }
        if (isset($response->expires_in)) {
            $this->access_token_expires_in = $response->expires_in;
        }
        // calculate when the access token expire
        if (isset($response->expires_in)) {
            $this->access_token_expires_at = time() + $response->expires_in;
        }
        return $response;
    }