Arctic v1

Intuit

Implements OpenID Connect.

For usage, see OAuth 2.0 provider.

import { Intuit } from "arctic";

const intuit = new Intuit(clientId, clientSecret, redirectURI);
const url: URL = await intuit.createAuthorizationURL(state, {
	// optional
	scopes // "openid" always included
});
const tokens: IntuitTokens = await intuit.validateAuthorizationCode(code);
const refreshedTokens: IntuitTokens = await intuit.refreshAccessToken(refreshToken);

Get user profile

Add the profile scope. Optionally add the email scope to get user email, the phone scope to get user phone, or the address scope to get the user address.

const url = await intuit.createAuthorizationURL(state, codeVerifier, {
	scopes: ["profile", "email", "phone", "address"]
});

Parse the ID token or use the userinfo endpoint. See ID token claims.

const tokens = await intuit.validateAuthorizationCode(code, codeVerifier);
const response = await fetch("https://accounts.platform.intuit.com/v1/openid_connect/userinfo", {
	headers: {
		Authorization: `Bearer ${tokens.accessToken}`
	}
});
const user = await response.json();