'authorization_code', 'client_id' => $client_id, 'client_secret' => $client_secret, 'code' => $authorization_code, 'redirect_uri' => $redirect_uri, ); $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query( $data ), ), ); $context = stream_context_create( $options ); $result = file_get_contents( $url, false, $context ); $access_token = json_decode( $result )->access_token; $_SESSION['access_token'] = $access_token; $refresh_token = json_decode( $result )->refresh_token; $_SESSION['refresh_token'] = $refresh_token; if ( $_SESSION['access_token'] ) { echo 'You have now been successfully logged in. Please close this tab and return to your WordPress site.'; ?>