---
title: "Exchange Opaque Token to JWT"
description: "An example of how to implement a Token Exchange (RFC 8693) plugin. In this example an opaque token is exchanged into a JWT."
url: "https://curity.io/resources/learn/token-exchange-opaque-to-jwt/"
date: "2024-08-07"
area: "tutorials"
topic: "code-examples"
pagegroup: "plugins-token-procedures"
repository: "https://github.com/curityio/token-exchange-opaque-to-jwt"
---

# Exchange Opaque Token to JWT

This example presents a Token Procedure plugin that implements an exchange from an opaque token into a JWT. The OAuth Token Exchange token procedure is compliant with RFC 8693.

## Installing the Plugin

You can build the plugin by issuing the command `mvn package`. This will produce a JAR files in the `target` directory, which can be installed.

To install the plugin, copy the compiled JAR (and all of its dependencies) into a new directory in the plugins directory, e.g. `${IDSVR_HOME}/usr/share/plugins/opaquetojwt` on each node, including the admin node. For more information about installing plugins, refer to the [Curity Plugin SDK](https://curity.io/docs/identity-server/developer-guide/plugins/).

## Configuration

You need to configure the Curity Identity Server to activate the plugin. The [Documentation](https://curity.io/docs/identity-server/profiles/token-profile/token-procedures/token-procedure-plugins/#configuring-and-using-token-procedure-plugins) describes how to set start using plugins. This plugin should be assigned to the `Token OAuth Token Exchange` flow on a `oauth-token` endpoint. The plugin itself does not have any settings.

Capability

Ensure that the client being used has the `OAuth 2.0 Token Exchange` capability enabled.

## Using the Plugin

The plugin is used by sending a Token Exchange request to the `oauth-token` endpoint. An example can look like:

```shell
curl -Ss -X POST \
https://idsvr.example.com/oauth/v2/oauth-token \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=urn:ietf:params:oauth:grant-type:token-exchange' \
-d 'client_id=clienta' \
-d 'client_secret=aaaaaa' \
-d 'subject_token_type=urn:ietf:params:oauth:token-type:access_token' \
-d 'subject_token=_0XBPWQQ...'
```

Expected output would be an access token in JWT format.
