This is the first step to integrate Yammer in your app. The SDK provides a couple of methods that enable a very fast Authentication process development, but in case you’re are curious about what happens behind the scenes, the full process is described here.


  • Windows 8

Make sure you have enabled the following capabilities in your Windows 8 App:

- Enterprise Authentication

- Internet (Client)

- Private Networks (Client & Server)

- Shared User Certificates

To do this, double-click the Package.appxmanifest and click on the Capabilities tab as shown above.

Note: The SDK uses the WebAuthenticationBroker to enable the OAuth2 signup process including networks requiring SSO login.

Open the App.xaml file and in the ResourceDictionary add the following objects:

<oAuthYammer:OAuthClientInfo x:Key="MyOAuthClientInfo"
ClientId="{your client Id}"  ClientSecret="{your client secret}"  RedirectUri="{your redirect uri}" />       
      <!--The lines below use the Model YammerBaseUris from the assembly Yammer.Oss.Api (namespace Yammer.Oss.Api)—>         
<yammerApiUris:YammerBaseUris x:Key="MyYammerUris”
UploadBaseUri="" />

for the OAuthClientInfo, it is EXTREMELY IMPORTANT that the information in every field matches exactly what’s on the web (including the RedirectUri), otherwise the authentication will fail.

The second object (YammerBaseUris) copy as is.

In the code behind file (App.xaml.cs) add the following getters:

public OAuthClientInfo MyOAuthClientInfo
		return Resources["MyOAuthClientInfo"] as OAuthClientInfo;

public YammerBaseUris MyYammerUris
			return Resources["MyYammerUris"] as YammerBaseUris;

These will help retrieve the values from the resource dictionary.


  • Standard Process

The code to do the OAuth process is basically 2 lines of code (the 3rd line is only used to store the information in the StateManager object to be able to call the other YAMMER API endpoints):

var authResponse = await OAuthUtils.LaunchSignIn(_clientConfig.ClientId, _clientConfig.RedirectUri, ssoEnabled);
var credentials = await _authRepository.AuthenticateAppAsync(authResponse.Code);

here is the method’s definition:

private async Task UpdateState(Credentials credentials)
	if (credentials == null)
		throw new UnauthorizedException("Invalid Credentials", HttpStatusCode.SeeOther);
	StateManager.Credentials = credentials;
	StateManager.CurrentUser = null;
	StateManager.CurrentUser = await _userRepository.GetCurrentUserAsync();
	if (credentials != null)
	IsBusy = false;
  • Single Sign On (SSO)

When Single Sign On is required, the AuthenticateAppAsync call will throw an exception of type SSOEnabledException. This makes the process of handling SSO Authentication easier. Below is one way of doing it:


public async void Login()
	HasErrored = false;
	IsBusy = true;     bool ssoEnabled = false;     try     {         await AuthorizationProcessAsync(ssoEnabled);     }     catch (Exception ex)     {         ssoEnabled = ex is SSOEnabledException;     }     if (ssoEnabled)     {         try         {             await AuthorizationProcessAsync(ssoEnabled);         }         catch (Exception ex)         {            var inEx = ex.InnerException ?? ex;             _eventAggregator.Publish(new ServerErrorMessage(inEx.Message));        }     }
private async Task AuthorizationProcessAsync(bool ssoEnabled)
{      var authResponse = await OAuthUtils.LaunchSignIn(_clientConfig.ClientId, _clientConfig.RedirectUri, ssoEnabled);      var credentials = await _authRepository.AuthenticateAppAsync(authResponse.Code);      UpdateState(credentials);


  • Windows Phone 8

Last edited Apr 26, 2014 at 10:14 PM by jmjc95, version 2