Arctic v1

Box

For usage, see OAuth 2.0 provider.

import { Box } from "arctic";

const box = new Box(clientId, clientSecret, redirectURI);
const url: URL = await box.createAuthorizationURL(state, {
	// optional
	scopes
});
const tokens: BoxTokens = await box.validateAuthorizationCode(code);

Get user profile

Use the /users/me endpoint.

const tokens = await box.validateAuthorizationCode(code);
const response = await fetch("https://api.box.com/2.0/users/me", {
	headers: {
		Authorization: `Bearer ${tokens.accessToken}`
	}
});
const user = await response.json();