Introduction:
If your organization uses Yammer as its internal socializing platform, you may be tempted to share files here to reach out to the set of audience specified by the Yammer group, instead of the conventional email method, which not only makes adding recipients seem cumbersome, but also formal.
Not only text messages, but using Yammer documented File Upload API files can also be uploaded programmatically to Yammer groups; however this method limits the maximum file size to only 4MB, which is very small.
This may not be a widely known limitation until someone tries to programmatically upload a large file to Yammer.
An alternative Yammer APIs which does not have any limitation on maximum file size is discussed in this article, though these set of APIs are not yet officially documented by Microsoft / Yammer team yet.
In this two-parts article we are going to create an AAD app (Part 1) and a C# console application (Part 2) to fetch AAD token by user login prompt and use the generated token to upload large files using unofficial Yammer API.
Pre-requisites
- Any version of Visual Studio (tested well with Visual Studio 2019)
- An active user account in Azure Active Directory having access to Yammer as well
- Azure Active Directory (AAD) app for authentication and generating the delegated token
Azure AD App
Register a new app in Azure Active Directory
Follow the below steps supported by the following screenshot:
- Sign into the Azure portal from https://portal.azure.com.
- If your account gives you access to more than one tenant, select your account in the top right corner, and set your portal session to the Azure AD tenant that you want.
- In the left-hand navigation pane, select the Azure Active Directory service, and then select App registrations > New registration.
- When the Register an application page appears, enter your application’s registration information:
- Name: Enter a meaningful application name that will be displayed to users of the app. (E.g. YammerADApp)
- Supported account types: Accounts in this organizational directory only.
- Redirect URI: Type as Public client/native (mobile & desktop) and URI to https://login.microsoftonline.com/common/oauth2/nativeclient
- When finished, select Register.
Grant permissions to Azure AD App
Open the newly created Azure AD App and perform the following steps:
- Click on API permission from left navigation.
- Click on Add a permission.
- From the Request API permissions screen Click on “Yammer”.
- Click on Delegated permissions.
- Select “user_impersonation” and click on Add Permission button.
- App would already have “Microsoft Graph” > “User.Read” permission; if not, add this permission as well following the steps above.
Enabling OAuth 2 Token generation for Azure AD App
Open the newly created Azure AD App and perform the following steps:
- Click on “Manifest” from left navigation.
- From right hand pane change the following JSON keys to true.
- “oauth2AllowIdTokenImplicitFlow”: true,
- “oauth2AllowImplicitFlow”: true
- Click on Save to save the changes
Capture Azure AD Application Identifier
Open the newly created Azure AD App and perform the following steps:
- Click on “Overview” from left navigation.
- From right hand pane copy the Application ID and Directory ID and save for future uses.
Summary
Once all the above steps are completed, we are ready to use the above Azure AD app for token generation and we are going to use the same in our C# application.
Do not miss the next part of this article where we create a C# console application that can be used to upload large files to Yammer using the AAD token.
Read Next Part :
How To Programmatically Upload Large Files to Yammer Using Rest API and AAD Token – Part 2