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
Size: 913
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Table of contents
This sample shows how to create a .NET Framework service that validates Exchange client identity tokens.
This sample requires the following:
Install-Package Microsoft.AspNET.MVC
.The sample solution contains the following key files:
IdentityToken project
`IdentityToken.xml
`: The manifest file for the mail add-in for Outlook.IdentityTokenWeb project
`IdentityTokenWeb/AppRead/Home/Home.html
`: The HTML user interface for the add-in.`IdentityTokenWeb/AppRead/Home/Home.js
`: The logic that handles requesting and using the identity token.IdentityTokenService project
`IdentityTokenService/Controllers/IdentityTokenController.cs
`: The service object that provides the business logic for the sample Web API service.
`IdentityTokenService/App_Start/WebApiConfig.cs
`: Binds the default routing for the Web API service.
Models folder
| File name | Description |
|——|——|
| `AuthClaimTypes.cs
` | The static object that provides identifiers for the parts of the client identity token. |
| `AuthMetadata.cs
` | The object that represents the authentication metadata document retrieved from the location specified in the client identity token. |
| `Base64UrlEncoder.cs
` | The static object that decodes a URL that has been base-64 URL-encoded, as specified in RFC 4648. |
| `Config.cs
` | Provides string values that must be matched in the client identity token. Also provides a certificate validation callback suitable for test use. |
| `DecodedJSONToken.cs
` | Represents a valid JSON Web Token (JWT) decoded from the base-64 URL-encoded client identity token. If the token is not valid, the constructor for the DecodedJSONToken object will throw an ApplicationException error. |
| `IdentityToken.cs
` | The object that represents the decoded and validated client identity token. |
| `IdentityTokenRequest.cs
` | The object that represents the REST request from the add-in. |
| `IdentityTokenResponse.cs
` | The object that represents the REST response from the web service. |
| `JsonAuthMetadataDocument.cs
` | The object that represents the authentication metadata document sent from the Exchange server. |
| `JsonTokenDecoder.cs
` | The static object that decodes the base-64 URL-encoded client identity token from the mail add-in for Outlook. |
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:
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.
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.
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.
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.
office-addins
.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.