Connect to Yammer from Azure Webjob

I am trying to connect to Yammer using their .NET SDK, but I have time managing this ... The goal of this exercise is to create an application in Azure that periodically - and AUTONOMOUSLY - communicates with Yammer and retrieves the latest posts from a specific Yammer group.

Does anyone know how to properly use the Yammer.NET SDK, say a console app that doesn't rely on the browser (direct user interaction aka) to connect successfully via OAuth authentication?


What I have tried :

Attempting to tell you what to do from the example provided on the .NET SDK page at developer.yammer.com , you can see it in the Standard Process section, which shows a function LaunchSignIn()

with the wrong signature! This example shows the usage:

var authResponse = await OAuthUtils.LaunchSignIn(_clientConfig.ClientId, _clientConfig.RedirectUri, ssoEnabled);

      

whereas the actual signature I get from the dll is:

void OAuthUtils.LaunchSignIn(string clientId, string RedirectUri)

      

I'll forgive the missing parameter ssoEnabled

... but the example states that the function receives a response, from which it is then retrieved Code

. This is, of course, the part missing from my attempt to call:

(awaitable) Task<AuthEnvelope> AuthClient.AuthenticateAppAsync(string code)

      

I looked at Google for information on using the Yammer.NET SDK but came up empty-handed. All examples of connecting to Yammer, but none of them are related to the .NET API. The only one I saw was the Yammer.NET API uploaded by a user , apparently the person who developed it, who posted the code on GitHub . I checked this example, but two parts of it - one for Windows Phone and one for Windows "Modern App" - both rely on an accessible browser object or something. There are redirects, I have to have a RedirectUri for Yammer to guide me ... This other example does this too - this was ONLY another example of using the .NET SDK I could find.

I am guessing that the reason the signature is different is that it is not actually the same function. The one I am trying to use is in Yammer.Oss.Api.Utils

, whereas in the sample app there are not even letters Utils

together other than the class name OAuthUtils

... which leads me to believe that it is possible under Yammer.Oss.Core.WinRT

, which luckily I cannot reference at all ... Yammer.Oss.Core

contains only the Collections

, Constants

, Extensions

, and Serialization

.

By the way, in the .NET SDK announcement (see first link above), the link to the documentation for the SDK leads to the Yammer support page.

+3


source to share


1 answer


Skip the .NET SDK and just do authorization yourself using the server stream . Then make HttpClient requests and add an Authorization header . The SDK can be useful in some modern applications, but for most people it is too complicated. When working with APIs manually, the worst thing you will have to deal with is deserializing JSON responses using JSON.NET or another JSON library.



You don't say you're trying to build, but AFAIK WebJobs don't have a UI, so you'll need to do authorization from a console app or website. Then store the resulting OAuth token where the WebJob can access it. If you need an OAuth token for each user, you will need to store them in a database, but make an effort to secure them because each OAuth token provides access to their Yammer account.

+1


source







All Articles