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

前端 未结 3 1268
[愿得一人]
[愿得一人] 2020-12-10 22:22

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.

相关标签:
3条回答
  • 2020-12-10 22:47

    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.

    0 讨论(0)
  • 2020-12-10 23:00

    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}'))
    
    0 讨论(0)
  • 2020-12-10 23:04

    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

    0 讨论(0)
提交回复
热议问题