Arctic v1

42 School

For usage, see OAuth 2.0 provider.

If you haven't done so already, you can create a new application at 42 Applications. Your application will receive an App UID and an App SECRET, both of which need to be provided. You'll also need to configure a redirectURI that matches the route in your application.

import { FortyTwo, FortyTwoTokens } from "arctic";

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

Get user profile

You can retrieve user information via the /v2/me endpoint.

const response = await fetch("https://api.intra.42.fr/v2/me", {
	headers: {
		Authorization: `Bearer ${tokens.accessToken}`
	}
});
const user = await response.json();

Refer to the /v2/me documentation to see which fields are available.