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

  • Question

  • 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!

    Monday, June 8, 2015 11:57 AM

Answers

  • Greetings, Ivan!

    This seems to be an authorization failure from Yammer, the authentication piece with AzureAD seems to be fine. As suggested above, you will need to work with Yammer and take this on their community forum.

    Thank you,

    Arvind

    Monday, June 15, 2015 7:52 PM

All replies

  • Greetings, Ivan!

    I'd suggest you to refer: https://developer.yammer.com/v1.0/docs/ for details on REST APIs. You might want to re-post / share your query on the Yammer Forum for better expert coverage.

    Thank you,

    Arvind

    Monday, June 8, 2015 7:43 PM
  • Hello,

    The documentation of Yammer rest APIs doesn't mention anything about Azure Authentication. It sggests to use Yammer's own authentication endpoint to get an access token. On the other hand, the Yammer option is available in Azure Management Portal when you configure app permissions in a Azure App. But there is no documentation about this.

    BR,

    Ivan

    Saturday, June 13, 2015 4:13 PM
  • Greetings, Ivan!

    This seems to be an authorization failure from Yammer, the authentication piece with AzureAD seems to be fine. As suggested above, you will need to work with Yammer and take this on their community forum.

    Thank you,

    Arvind

    Monday, June 15, 2015 7:52 PM