问题描述
我工作的ASP.NET Web应用程序,从Yammer的读取数据。我已经成功地acomplished验证和获取信息从家的网络。
I'm working on an ASP.NET web application that reads data from Yammer. I've successfully acomplished authentication and getting messages from the "home" network.
现在我想切换到另一个网络,并从它那里得到的消息。我读过的所有和专门的部分,其中列明了以下内容:
Now I want to switch to another network and get messages from it. I've read all the documentation and specifically the Networks section which states the following:
便于切换不同的Yammer网络之间的用户。所有
Yammer的Web请求URL中包含一个网络固定链接
()来表示
网络环境。 API请求每件都用不同的OAuth令牌
用户/网络的结合。
端点:返回网络到当前用户具有列表
访问。支持included_suspended参数。
Endpoint: Returns a list of networks to which the current user has access. Supports included_suspended parameter.
GET https://www.yammer.com/api/v1/networks/current.json
好了,我需要得到用户/网络相结合相应的令牌。完善。
我做了 GET
请求到网络/ current.json
终端和我得到的所有的网络当前用户具有访问权限至。大。现在,这里是令牌?他们不是JSON响应。
Ok, so I need to get the corresponding token for the user/network combination. Perfect.I do a GET
request to that networks/current.json
endpoint and I get all the networks the current user has access to. Great. Now, where are the tokens? They aren't in the json response.
所以...
- 如何得到使用REST Yammer的外部网络的消息
通过服务器端的code API? - 如何获得令牌外部
网络?
更新
继布莱恩的建议:
- 我做了
GET https://www.yammer.com/api/v1/oauth/tokens.json
传递当前令牌认证头(承载:XXXXXXXXX
) - 这将返回两个网络,我使用用户在该家庭和外部。有一件事我注意到的是,
USER_ID
是每个网络不同。我不知道这是另一个用户或同一用户拥有不同的USER_ID
为每个网络。 - 现在,我想从其他网络的消息,所以我做了
- I do a
GET https://www.yammer.com/api/v1/oauth/tokens.json
passing the current token in the authentication header (Bearer: xxxxxxxxx
) - This returns the 2 networks the user I'm using is in. The home and the external. One thing I noticed is that the
user_id
is different for each network. I don't know if that's another user or if the same user has a differentuser_id
for each network. - Now I want to get messages from the other network so I do a
GET https://www.yammer.com/api/v1/messages.json
但现在使用令牌我从 tokens.json
端点得到了外部网络。但我得到以下响应:
but now using the token for the external network I got from the tokens.json
endpoint. But I get the following response:
{
"response":
{
"stat":"fail",
"code":17,
"message":"Attempt to access a protected resource failed."
}
}
再次,根据DOC端点是模拟和支付的Yammer网络仅限于经过验证的管理员用户。
And again, according to the doc that endpoint is for impersonation and restricted to verified admin users in paid Yammer networks.
我不知道真的。
更新2
在上面的更新描述的过程适用于创建该应用Yammer的用户(我)。我在用着。除非我该网络中的其他我的用户不能得到来自外部网络的消息。因此,它好像他们使用的是我的令牌,但是这是不可能的,除非有在API中的错误。
The process described in the above update works for the user (me) that created the Yammer App. I'm using. Other users can't get messages from external networks unless I'm in that network. So it seems like they are using my tokens, but that's impossible unless there's a bug in the API.
推荐答案
您需要打的。这个主题是过上Zapier博客。他们的博客指定一个作为的access_token查询字符串参数,但不再支持。指定在Yammer的开发者网站如图所示为在授权头当前用户的访问令牌。
You need to hit https://www.yammer.com/api/v1/oauth/tokens.json. This topic is covered over on the Zapier blog. Their blog specifies an access_token as a query string parameter, but that is no longer supported. Specify the access token for the current user on the Authorization header as shown on the Yammer developer site.
这篇关于Yammer的REST API:如何获得访问令牌外部网络?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!