Yammer REST API: How to get access tokens for external networks?

帅比萌擦擦* 提交于 2019-11-28 11:47:37

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.

So far what i have discovered is this: Due to some cross domain restriction, the SDK creates a hidden iframe on the page to serve as a proxy bridge to use the users primary network credentials and get access to external network resources. The network parameter is the key in the puzzle.

The obtained token can be then manually set for further requests whenever the page is reloaded, avoiding the login window to show up again.

yam.platform.login({ network: '{your-permalink-goes-here}' }, function (data) {

    console.log('login-status: ',data)
    if(data.status ==='connected')
        yam.platform.request({
            url: "oauth/tokens.json"     
            , method: "GET"
            , success: function (tokens) { console.log('user-tokens:',tokens); }
            , error: function (err) { alert("There was an error with the request."); }
        });
})

Then for next requests, setAuthToken does the trick.

yam.platform.setAuthToken('{the-token-goes-here}'))
Rupesh

If you want your app to work in SSO enabled Network, you need to globalize your app. For this you need to raise a ticket to the yammer helpdesk.

Refer: yammer oauth2 returning 403 Client Error: Forbidden

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!