Yammer API issue - get groups showing error

2019-09-16 18:27发布

I am integrating yammer features in our app (web-front-end stack and using Yammer JS SDK). So, I want get all the groups of a login-ed user.

Inorder to get all the groups, I have tried to call the end points in two ways, /groups.json=mine using SDK - resposne showing method not authorised and www.yammer.com/api/v1/groups.json=mine=1 using normal ajax GET request- throwing access control origin issue.

API is perfectly working, while tested using google chrome browser - by disabling web security.

My question is how I can call www.yammer.com/api/v1/API_END_POINTS without cross origin issue using yammer JS SDK or any other technique?

I found an related answer in this Q & A , but still showing error for me.

Error :

XMLHttpRequest cannot load https://www.yammer.com/api/v1/groups.json?mine=1. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://xxx.dev.com' is therefore not allowed access.

Code I have tried after login code :

1# GET Request - return $http.get('https://www.yammer.com/api/v1/groups.json?mine=1')

2# yammer JS SDK -

yam.platform.request({
        url: "groups.json?mine=1",
        method: "GET",
        success: function (group) {
          console.log(group);
        },

        error: function (group) {
          console.error("There was an error with the request.", group);
        }
      });

I have already commented different Q&As for the opinion, but no luck, no one replied.

PS - My all other yammer APIs are working(login, post, message etc), which listed in Yammer REST API Docs, only I am facing problem with APIs hosted in wwww.yammer.com/api/v1, Not api.yammer.com

Thanks in advance

1条回答
Emotional °昔
2楼-- · 2019-09-16 19:22

You should register an App in Yammer dev console, specify allowed origins, get an API key and send it along with request.

See https://developer.yammer.com/docs/api-requests for more info.

查看更多
登录 后发表回答