Golang单足/两足oauth 1.0a身份验证

I am looking for a library to help me authenticate with a service via oauth 1.0a using one-legged authentication. I only have a consumerKey, consumerSecret and resource url.

Examples are available in curl, PHP and Python. I am trying to authenticate with GoLang.

curl
-X GET
-H "Content-Type: application/json"
-H 'Authorization: OAuth realm="https://example.com",oauth_consumer_key="1234-5678-91011",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1424789327",oauth_nonce="abcde",oauth_version="1.0",oauth_signature="3iwWBq%2FHaBcDl9Q1o%2BjAc%2BKz8J%2FE%3D"'
https://example.com

php

require 'vendor/autoload.php';

use Guzzle\Http\Client;
use Guzzle\Plugin\Oauth\OauthPlugin;

$client = new Client('https://example.com');
$oauth = new OauthPlugin(array(
    'consumer_key'    => '1234-5648-9101',
    'consumer_secret' => 'abcde',
));
$client->addSubscriber($oauth);

$response = $client->get('/')->send();
echo $response->getBody();

Python

from requests_oauthlib import OAuth1Session

key = '1234-5648-9101'
secret = 'abcde'
example = OAuth1Session(key, client_secret=secret)
url = 'https://example.com'
r = example.get(url)
print r._content

I have looked at many oauth libraries in Golang.

https://github.com/mrjones/oauth, requires: RequestTokenUrl, AccessTokenUrl, AuthorizeTokenUrl and callback url.

http://godoc.org/github.com/nhjk/oauth, requires: a tokenKey and tokenSecret as well as the consumerKey and consumerSecret.

Is there a library I can use which will allow me to authenticate with the service just as easily as php and python examples above? If i can use one of libraries above, could somebody provide a code snippet example? Anything I try just returns unauthorized responses.

Golang has a different aproach for frameworks, for one reason, you do not need them. You can easyily set the header of the response with the standard http package. When you get the hang of it, you realize that you are dealing with first class objects, which is what those other language frameworks are trying to implement.

Something like this function

  func saveHandler(w http.ResponseWriter, r *http.Request) {
    // allow cross domain AJAX requests
    w.Header().Set("Access-Control-Allow-Origin", "*")
}