How to authenticate REST API with Go client and Oauth1?

Viewed 68

Trying to consume REST API which uses Oauth1 with GO client. With Posmant I'm using this configurations and it works fine: auth and advanced

My Go code look like this:

config := oauth1.Config{
    ConsumerKey:    "key",
    ConsumerSecret: "secret",
    Realm:          "realName",
    Signer:         new(oauth1.HMAC256Signer),
}

token := oauth1.NewToken("token", "tokenSecret")

httpClient := config.Client(oauth1.NoContext, token)

resp, _ := httpClient.Get(URL)
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Printf("Raw Response Body:\n%v\n", string(body))

What configuration is missing in my code? Getting 401 error.

0 Answers
Related