[wp-trac] [WordPress Trac] #21163: Blogger Importer Invalid Tokens
WordPress Trac
wp-trac at lists.automattic.com
Thu Jul 5 17:21:36 UTC 2012
#21163: Blogger Importer Invalid Tokens
--------------------------+----------------------------
Reporter: Workshopshed | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: WordPress.org
Component: Import | Version:
Severity: normal | Resolution:
Keywords: |
--------------------------+----------------------------
Comment (by Workshopshed):
Updated get_oauth_link
{{{
function get_oauth_link()
{
// Establish an Blogger_OAuth consumer
$request_token_endpoint =
'https://www.google.com/accounts/OAuthGetRequestToken';
$authorize_endpoint =
'https://www.google.com/accounts/OAuthAuthorizeToken';
$test_consumer = new Blogger_OAuthConsumer('anonymous',
'anonymous', null); // anonymous is a google thing to allow non-registered
apps to work
//prepare to get request token
//https://developers.google.com/accounts/docs/OAuth_ref#RequestToken
$sig_method = new Blogger_OAuthSignatureMethod_HMAC_SHA1();
$parsed = parse_url($request_token_endpoint);
$params = array('callback' => $base_url, 'scope' =>
'http://www.blogger.com/feeds/', 'xoauth_displayname' => 'WordPress');
$req_req =
Blogger_OAuthRequest::from_consumer_and_token($test_consumer, null, "GET",
$request_token_endpoint, $params);
$req_req->sign_request($sig_method, $test_consumer, null);
// go get the request tokens from Google
$req_response = wp_remote_get($req_req->to_url(),
array('sslverify' => false));
if (is_wp_error($req_response))
{
return $req_response;
}
$req_token = wp_remote_retrieve_body($req_response);
// parse the tokens
parse_str($req_token, $tokens);
$oauth_token = $tokens['oauth_token'];
$oauth_token_secret = $tokens['oauth_token_secret'];
// todo: add validation so these never get passed as blank
$callback_url =
admin_url('admin.php?import=blogger&noheader=true&token='.$oauth_token.'&token_secret='.$oauth_token_secret);
return array('url' => $authorize_endpoint, 'oauth_token' =>
$oauth_token, 'oauth_callback' => $callback_url);
}
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21163#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list