page_type | description | products | languages | extensions | urlFragment | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sample |
This sample demonstrates a C# Messaging Extension that implements link unfurling for Reddit links in Microsoft Teams. |
|
|
|
officedev-microsoft-teams-samples-msgext-link-unfurling-reddit-csharp |
This comprehensive C# sample illustrates how to implement a Messaging Extension for Reddit links in Microsoft Teams, featuring robust link unfurling capabilities. With built-in user authentication and configurable settings, the extension streamlines the process of sharing and interacting with Reddit content seamlessly in Teams.
This sample demonstrates the following concepts:
- Link Unfurling
- Bot Token Service & User Authentication
- Message Extension settings page
- Message Extension logout
You will need to complete the following before running the code
Follow the directions for creating a messaging extension.
- Register a bot with Azure Bot Service, following the instructions here.
- Ensure that you've enabled the Teams Channel
- While registering the bot, use
https://<your_tunnel_domain>/api/messages
as the messaging endpoint.NOTE: When you create your bot you will create an App ID and App password - make sure you keep these for later.
- You must use the 'Bot Channel Registration' so Bot Framework token service can be registered to manage tokens.
- The
reddit.com
andwww.reddit.com
domains should be registered in the 'messageHandlers' for the Teams App. If these are not included, the extension will not trigger for reddit links!
Make sure to note the app id and password for later.
Go To The Reddit App Preferences and register a new app for Reddit using the following parameters.
Parameter | Value |
---|---|
Type | web app |
redirect uri | Not required |
Description | Your own description |
About Url | Url to your own about page |
Afterwards be sure to save the client id
and the secret
for the next step.
In the Azure portal, navigate to the Bot Channels Registration for the app and select the Settings
menu under Bot management
At the bottom of the blade press Add Setting
, this will open the New Connection Setting
Blade.
Parameter | Value |
---|---|
Name | reddit |
Service Provider | Generic Oauth 2 |
Client Id | Reddit Client Id from Configure Reddit App |
Client Secret | Reddit Secret from Configure Reddit App |
Authorization Url | https://www.reddit.com/api/v1/authorize.compact |
Refresh Url | https://www.reddit.com/api/v1/access_token |
Scopes | read |
/dotnet
the ASP.NET Core implementation which uses 2 legged OAuth for Reddit API calls/dotnet_user_auth
the ASP.NET Core implementation which uses the 3 legged OAuth for Reddit API calls on behalf of the user.