JavaScript¶
We provide an official client for JavaScript. You can install it with npm
:
Create a Fief
client¶
The Fief client provides all the necessary methods to manage OAuth2 authentication, validate access tokens and refresh them.
const fief = new Fief({
baseURL: 'https://fief.mydomain.com', // (1)!
clientId: 'YOUR_CLIENT_ID', // (2)!
clientSecret: 'YOUR_CLIENT_SECRET', // (3)!
});
-
Base URL of your Fief tenant
You can find it in the admin dashboard, in the Tenants list. More info
-
ID of your Fief client
You can find it in the admin dashboard, in the Clients list. More info
Info
A first client is always created for you when you create your instance. When getting started, you should use this one.
-
Secret of your Fief client
You can find it in the admin dashboard, in the Clients list. More info
Info
A first client is always created for you when you create your instance. When getting started, you should use this one.
Client secret is not safe in browser-based applications
If you build a browser-based application in JavaScript, the Client Secret is not safe: the end-user can easily find it in the source code.
To circumvent this, Fief allows to omit the client secret for clients with the public type. However, a PKCE code challenge will be required during the authorization flow.
What's next?¶
JavaScript being a vast ecosystem both for browsers and servers, integration paths can be quite different following your use-case.
To help you further, we provide you helpers and examples for popular JavaScript frameworks and technologies, like React.