OfficeDev/Outlook-Add-in-JavaScript-ValidateIdentityToken

Name: Outlook-Add-in-JavaScript-ValidateIdentityToken

Owner: Office Developer

Description: Shows how to create a .NET Framework service that validates Exchange client identity tokens.

Created: 2015-08-13 22:58:49.0

Updated: 2018-05-16 02:13:12.0

Pushed: 2018-01-31 20:28:35.0

Homepage:

Size: 913

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Outlook Add-in: Validate a client identity token using the .NET Framework

Table of contents

Summary

This sample shows how to create a .NET Framework service that validates Exchange client identity tokens.

Prerequisites

This sample requires the following:

Key components of the sample

The sample solution contains the following key files:

IdentityToken project

IdentityTokenWeb project

IdentityTokenService project

Description of the code

This sample shows you how to create a .NET Framework service that validates an Exchange client access token. The Exchange server issues a token that is unique to the mailbox on the server. You can use this token to associate a mailbox with services that you provide to a mail add-in for Outlook.

The sample is divided into two parts:

The web service uses the following steps to process the token:

  1. Decodes the identity token to get the URL for the Exchange server's authentication metadata document. During this step, the service also checks whether the token has expired and checks the version number on the token.
  2. If the identity token passes the first step, the service uses the information in the authentication metadata document to get the certificate that was used to sign the token from the server.
  3. If the token is valid, the service returns it to the mail add-in for Outlook for display.

The service does not use the token in any way. It responds with the information contained in the token, or with an error message if the token is not valid.

This sample also requires an X.509 certificate validation function that allows the service to respond to requests that are signed with a self-signed certificate issued by the Exchange server. The Exchange server will use this self-signed certificate by default. If your Exchange server has a valid certificate that traces back to a root provider, this validation function is not required. For more information about the validation function, see Validating X509 Certificates for SSL over HTTP.

Build and debug

The add-in will be activated on any email message in the user's Inbox. You can make it easier to test the add-in by sending one or more email messages to your test account before you run the sample.

  1. Open the solution in Visual Studio, and press F5 to build and deploy the sample.
  2. Connect to an Exchange account by providing the email address and password for an Exchange 2013 server, and allow the server to configure the email account.
  3. In the browser, log on with the email account by entering the account name and password.
  4. Select a message in the Inbox, and click Validate Identity Token in the add-in bar that renders above the message.
    The add-in loads and displays the contents of the client identity token.

If you're running the sample on an Exchange server that's using the default self-signed certificate, you'll get a certificate error when the web browser opens. After you verify that the browser is opening the correct URL by looking at the web address, select Continue to this Web site to start Outlook Web App.

Troubleshooting

You might encounter the following issues when you use Outlook Web App to test a mail add-in for Outlook:

If the add-in loads but does not run, try to build the solution in Visual Studio (Build > Build Solution). Check the Error List for missing dependencies and add them as needed.

Questions and comments

Additional resources
Copyright

Copyright (c) 2015 Microsoft. All rights reserved.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.