As you may know, there are lots of Azure Active Directory libraries that are available for different platforms, such as .Net, Ruby, Node.js, Python, Java etc, that could help you get started with development with minimal effort. In the same vein, I have had several interactions with customers and partners that do not fully understand the abstractions that are behind these libraries, as a result, this blog will focus on how to manually generate an ADAL token – without any library, and how to use the obtained token to consume Yammer APIs.
Add an application in Azure AD
Navigate to Azure portal – > Active Directory -> Add :
Once the app has been created, navigate to the app, click Configure, then “Add Application”:
Go back to the app and delegate Read/Write permission to the Yammer Platform:
On the same page, select Key duration, then Save. Please copy the generated key into somewhere secure before exiting the page as it cannot be recovered.
Obtaining an ADAL token:
Click the “View Endpoints” links and copy the TOKEN and AUTHORISATION endpoints into a notepad:
Authorisation: The first step is to authorise and get the user’s consent – using the authorisation endpoint. Append :
- response_type and
- client_id (copy this from app’s page in Azure AD)
as parameters to the authorise endpoint as shown below:
Copy the URL into a browser and you be should redirected to the app’s login page. Login with an active user in Office 356 and grant consent. If the login is successful, you should be further redirected to the specified redirect_uri. Copy the code from the browser’s url:
Token: Next, launch Postman or your preferred RESTful client, input the following parameters, and send a POST request to the token endpoint in the format shown in the screenshot-
You should get a 200 OK response if all went well.
Yammer REST API
Copy the full value of the “access_token”. We can now use this token to perform actions in Yammer. How cool!
To do that, you’d need to send the access token as a Bearer token in the request’s Authorisation header.
Try it out by sending a GET request to the current user endpint – https://www.yammer.com/api/v1/users/current.json
- ADAL token is not supported by some Yammer API endpoints yet. The autocomplete endpoint for example does not accept ADAL tokens.
- Yammer does not support ADAL tokens from web applications due to CORS limitation. It only works from client/console applications.
- Bear in mind that this integration is still in a preview state (as at the time of writing this blog)
- The Yammer network and or the user must be mapped to Office 365 as a prerequisite. So if your network is still using single sign -on (SSO), you’d need to disable it first as Office 365 sign-in for Yammer is mutually exclusive to SSO.
Please follow the steps that are described in this blog to perform self/preliminary troubleshooting in your development environment. Contact Yammer support if you need further help.