Quantcast
Channel: Azure Active Directory forum
Viewing all articles
Browse latest Browse all 16000

Yammer REST API: 401 Unauthorized when using Azure AD token and Yammer Delegated Permissions

$
0
0

I am creating an Azure AD App that is using the new Yammer delegated permissions preview to post a message to Yammer using the access token that I obtained from Azure AD. Unfortunately, I get a 401 Unauthorized response when trying to call Yammer Rest APIs.

Here is the code sample:

var resourceId = "https://www.yammer.com";
var endpointUrl = "https://www.yammer.com/api/v1/messages/following.json";
AuthenticationHelper helper = new AuthenticationHelper();
helper.EnsureAuthenticationContext(AuthenticationHelper.AuthorityMultitenant, resourceId);
var token = helper.AuthenticationResult.AccessToken;
HttpClient hc = new HttpClient();
hc.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var result = await hc.GetAsync(new Uri(new Uri("https://www.yammer.com"), endpointUrl));

Here I get the 401 Unauthorized, with a message "Authentication failure". I tried also with api.yammer.com instead of www.yammer.com, with no change. I know that the token-getting functions are working, as I tested them with other Office 365 REST APIs.

My assumption is that the token has unaccepted format, but isn't it supposed to accept Azure Tokens now that the Delegated Permissions were added? Or am I using the wrong resource ID and endpoint?

Hopefully someone could give me some hints! Thank you!


Viewing all articles
Browse latest Browse all 16000

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>