Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
page_type description products languages extensions contentType createdDate
sample
Messaging Extension with Link Unfurling Samples for Reddit Links
office-teams
office
office-365
csharp
samples
07-07-2021 13:38:27

Link Unfurling for Reddit Links

Preview Image

This repository is a full implementation of link unfurling for Reddit links in dotnet.

This sample demonstrates the following concepts:

  • Link Unfurling
  • Bot Token Service & User Authentication
  • Message Extension settings page
  • Message Extension logout

Setup

You will need to complete the following before running the code

Create Messaging Extension

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_ngrok_url>/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.

  1. You must use the 'Bot Channel Registration' so Bot Framework token service can be registered to manage tokens.
  2. The reddit.com and www.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.

Configure Reddit App

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.

Configure Bot Framework Authentication

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

Directory Structure

  • /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.

References