Net :: OAuthを使用して、Latitude用のGoogleのOAuthAPIに対して認証するスクリプトを作成しました。正しく認証されます(APIからデータを正常にフェッチできるため)。ただし、履歴エントリを追加しようとすると、401 Unknown authorization header
応答が返されます。私は次のコードを使用しています:
my $location_data = $json->encode(\%data);
$request = Net::OAuth->request("protected resource")->new(
consumer_key => $c_key,
consumer_secret => $c_secret,
token => $token,
token_secret => $token_secret,
verifier => $verifier,
request_url => 'https://www.googleapis.com/latitude/v1/location',
request_method => 'POST',
signature_method => $s_method,
timestamp => time,
nonce => &nonce(),
extra_params => {
key => $s_key
}
);
$request->sign;
$ua->default_header("Authorization", $request->to_authorization_header);
$ua->default_header("Content-Type", "application/json");
my $res = $ua->post('https://www.googleapis.com/latitude/v1/location?key=' . $s_key,
Content => $location_data);
すべての変数はAPIのフェッチ部分で使用されるので、それらはすべて問題ないことがわかります。投稿に正しいURLを使用しているかどうかはわかりません。また、上記のサンプルにあるものとを試しました$request->to_url
。
任意の提案をいただければ幸いです。