问题
I am trying to set up an internal RESTful API using NodeJS that communicates with various social media services. One of the services we use is Yammer. Yammer uses oAuth for validation but they offer a permanent validation token. For some reason I am having issues passing the token when I try to POST. From their docs it appears that all I have to do is post everything in the URL. an example would be
POST https://yammer.com/mycompany.com/api/v1/messages.json?body=Testing&access_token=<myAccessToken>
When I do this I do not get a response. Is there something I am missing?
I would also like to add that testing GET this way does not work either
GET https://yammer.com/mycompany.com/api/v1/messages.json?access_token=<myAccessToken>
回答1:
The Yammer API requires the OAuth data to be in the header. If you look at their example for Getting Data, you'll see the request looks like.
GET /api/v1/messages/favorites_of/1234 HTTP/1.1
HOST: www.yammer.com
Authorization: OAuth oauth_consumer_key="KsTROcNF1Fx3e1PwA",oauth_token="vlVH7A7DOm9wXuHdv58A",oauth_signature_method="PLAINTEXT",oauth_timestamp="1297383841092",oauth_nonce="1047685618",oauth_verifier="E4F8",oauth_signature="yPsEvDnNPIA8xGCFLvMJ73K0DD9ivMpATJeFOSo%26fSFh9UPkHQ6oRwK5OTne33ltnSnbQ9XrAhA72heg"
The OAuth data is in the Authorization header and not in the URL. The only time you have any OAuth data in the URL is when you do the authorize.
回答2:
I've created this gist where I used the Yammer API to post a status after a build completion through Fabric. Its in Python, but possibly it can point you in the right direction.
I am assuming you got the right Access Token though, as thats critical.
I recommend using this library to get the access token, as its pretty simple and easy to use. This will ensure you have the right access token.
来源:https://stackoverflow.com/questions/7294723/oauth-and-yammer