WPCF7_Service_OAuth2::request_token()
Метод класса: WPCF7_Service_OAuth2{}
Хуков нет.
Возвращает
null
. Ничего.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->request_token( $authorization_code );
- $authorization_code (обязательный)
- -
Код WPCF7_Service_OAuth2::request_token() WPCF7 Service OAuth2::request token CF7 5.7.4
protected function request_token( $authorization_code ) { $endpoint = add_query_arg( array( 'code' => $authorization_code, 'redirect_uri' => urlencode( $this->get_redirect_uri() ), 'grant_type' => 'authorization_code', ), $this->token_endpoint ); $request = array( 'headers' => array( 'Authorization' => $this->get_http_authorization_header( 'basic' ), ), ); $response = wp_remote_post( sanitize_url( $endpoint ), $request ); $response_code = (int) wp_remote_retrieve_response_code( $response ); $response_body = wp_remote_retrieve_body( $response ); $response_body = json_decode( $response_body, true ); if ( WP_DEBUG and 400 <= $response_code ) { $this->log( $endpoint, $request, $response ); } if ( 401 == $response_code ) { // Unauthorized $this->access_token = null; $this->refresh_token = null; } else { if ( isset( $response_body['access_token'] ) ) { $this->access_token = $response_body['access_token']; } else { $this->access_token = null; } if ( isset( $response_body['refresh_token'] ) ) { $this->refresh_token = $response_body['refresh_token']; } else { $this->refresh_token = null; } } $this->save_data(); return $response; }