Yammer REST API:如何获取外部网络的访问令牌? [英] Yammer REST API: How to get access tokens for external networks?

查看:29
本文介绍了Yammer REST API:如何获取外部网络的访问令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个从 Yammer 读取数据的 ASP.NET Web 应用程序.我已成功完成身份验证并从家庭"网络获取消息.

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 中包含网络永久链接(https://www.yammer.com/network_permalink/resource_path) 表示网络上下文.API 请求对每个请求使用不同的 OAuth 令牌用户/网络组合.

Facilitates switching a user between different Yammer networks. All Yammer web requests contain a network permalink in the URL (https://www.yammer.com/network_permalink/resource_path) to denote the network context. API requests use a different OAuth token for each user/network combination.

Endpoint:返回当前用户访问的网络列表使用权.支持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

好的,所以我需要为用户/网络组合获取相应的令牌.完美的.我向该 networks/current.json 端点发出 GET 请求,并获取当前用户有权访问的所有网络.伟大的.现在,令牌在哪里?它们不在 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.

所以...

  • 如何使用 Yammer REST 从外部网络获取消息API 通过服务器端代码?
  • 如何获取外部令牌网络?

更新

遵循布赖恩的建议:

  1. 我做了一个 GET https://www.yammer.com/api/v1/oauth/tokens.json 在身份验证标头中传递当前令牌(Bearer: xxxxxxxxx代码>)
  2. 这将返回我正在使用的用户所在的 2 个网络.家庭和外部网络.我注意到的一件事是每个网络的 user_id 是不同的.我不知道这是另一个用户,还是同一用户对每个网络有不同的 user_id.
  3. 现在我想从其他网络获取消息,所以我做了一个
  1. I do a GET https://www.yammer.com/api/v1/oauth/tokens.json passing the current token in the authentication header (Bearer: xxxxxxxxx)
  2. 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 different user_id for each network.
  3. 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."
     }
 }

再一次,根据文档,该端点用于模拟并且仅限于付费 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.

推荐答案

你需要点击 https://www.yammer.com/api/v1/oauth/tokens.json.该主题在 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:如何获取外部网络的访问令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆