Arctic v1

Atlassian

For usage, see OAuth 2.0 provider.

import { Atlassian } from "arctic";

const atlassian = new Atlassian(clientId, clientSecret, redirectURI);
const url: URL = await atlassian.createAuthorizationURL(state, {
	// optional
	scopes
});
const tokens: AtlassianTokens = await atlassian.validateAuthorizationCode(code);
const tokens: AtlassianTokens = await atlassian.refreshAccessToken(refreshToken);

Get user profile

Add the read:me scope and use the /me endpoint.

const url = await atlassian.createAuthorizationURL(state, {
	scopes: ["read:me"]
});
const tokens = await atlassian.validateAuthorizationCode(code);
const response = await fetch("https://api.atlassian.com/me", {
	headers: {
		Authorization: `Bearer ${tokens.accessToken}`
	}
});
const user = await response.json();