# How to get the license status of an Atlassian Connect app

**URL:** <https://community.developer.atlassian.com/t/how-to-get-the-license-status-of-an-atlassian-connect-app/57066>\
**Category:** Atlassian Developer Tools\
**Tags:** licensing, ac-express, atlassian-connect\
**Created:** [March 29, 2022, 10:29am UTC](https://community.developer.atlassian.com/t/how-to-get-the-license-status-of-an-atlassian-connect-app/57066 "2022-03-29T10:29:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/david/32/44964_2.png) [@david](https://community.developer.atlassian.com/u/david)\
**Post date:** [March 29, 2022, 10:29am UTC](https://community.developer.atlassian.com/t/how-to-get-the-license-status-of-an-atlassian-connect-app/57066/1 "2022-03-29T10:29:37Z")

</div>

ℹ _This is not a question. I’m writing this down here as I often question my knowledge of what is correct and I’d like to find this information in a single article. If you wish to comment to correct this, please do so and I’ll update the post with the corrected information_

For Atlassian Connect apps, there are 2 license states that can be found from within the app:

- active
- none

…but several ways to locate this information.

## Getting the license status

There are various methods:

### Get license status from the request parameter on the app’s URL

Jira & Confluence will request your app with a URL similar to this

```auto
https://your-special.app/some-screen?jwt={jwt}&{...}&lic=active
https://your-special.app/some-screen?jwt={jwt}&{...}&lic=none

```

Simply test for this request parameter:

```auto
const getUrlSearchParam = (key) =>
  new URLSearchParams(location.search).get(key);
		
const license = getUrlSearchParam('lic'); // `active` or `none`

```

### Get license status from the context

#### When using JWT based auth

`AP.context.getToken` gives a JSON object

```auto
AP.context.getToken((token) => { // token is a JSON object
  const isLicenseActive = token.context.license.active; // true or false
});

```

#### When auth is `NONE`

`AP.context.getToken` gives a JWT string that needs parsing…

```auto
const parseJwt = (token) => { // @see: https://stackoverflow.com/a/38552302
  var base64 = token.split(".")[1].base64Url.replace(/-/g, "+").replace(/_/g, "/");
  var jsonPayload = decodeURIComponent(window.atob(base64).split("").map((c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)) .join(""));
  return JSON.parse(jsonPayload) || null;
};

AP.context.getToken((token) => { // token is a JSON object
  const payload = parseJwt(token); // parse the token to reveal the payload
  const isLicenseActive = payload?.context?.license?.active || false;
});

```

### Get the license from the REST API for the app

🔴 &nbsp; _Warning, this may give false data because of [MC-1001](https://ecosystem.atlassian.net/browse/MC-1001)_

This method gives you the most detail on the “current state” of the license:

```auto
AP.request('/rest/atlassian-connect/1/addons/{addon-key}')
  .then(data => JSON.parse(data.body))
  .then(data => {
  	console.log(data); // spew out everything
	const isLicenseActive = data?.license?.active || false;
  });

```

Examples output of the console.log output…

#### Unlicensed app

This may just be what you get from a developer license/private listing – need to confirm this.

```auto
{
	"key": "{addon-key}",
	"version": "X.Y.Z-AC",
	"installedDate": "2021-11-10T10:17:14Z",
	"lastUpdated": "2021-11-25T15:03:43Z",
	"state": "ENABLED",
	"host": {
		"product": "Confluence"
	},
	"links": {
		"marketplace": [
			{
				"href": "https://marketplace.atlassian.com/plugins/{addon-key}"
			}
		],
		"self": [
			{
				"href": "https://yourinstance.atlassian.net/wiki/rest/atlassian-connect/1/addons/{addon-key}"
			}
		]
	}
}

```

#### Active evaluation license

```auto
{
	"key": "{addon-key}",
	"version": "X.Y.Z-AC",
	"installedDate": "2021-11-10T10:17:14Z",
	"lastUpdated": "2021-11-25T15:03:43Z",
	"state": "ENABLED",
	"host": {
		"product": "Confluence"
	},
	"license": {
		"active": true,
		"type": "COMMERCIAL",
		"evaluation": true,
		"supportEntitlementNumber": "SEN-XXXXX",
		"entitlementId": "abcdef-ghi-jki-9103-gfdgfdg12345",
		"entitlementNumber": "E-XXX-XXX-XXX-XXX"
	},
	"links": {
		"marketplace": [
			{
				"href": "https://marketplace.atlassian.com/plugins/{addon-key}"
			}
		],
		"self": [
			{
				"href": "https://yourinstance.atlassian.net/wiki/rest/atlassian-connect/1/addons/{addon-key}"
			}
		]
	}
}

```

That’s it. Let me know if there’s any other ways 🙂

In my [next post](https://community.developer.atlassian.com/t/what-is-the-atlassian-connect-licensing-lifecycle/57067), I’m asking what do `lic=active` & `lic=none` actually mean?
