Setup and Authorization
FreJun provides two ways to authenticate your application:
- OAuth 2.0 - Standard OAuth flow for third-party applications
- API Key - Simple authentication using an API key
OAuth 2.0 Authentication
Section titled “OAuth 2.0 Authentication”FreJun supports the OAuth 2.0 standard for authorizing third-party applications.
To get started:
- Visit https://product.frejun.com and log in.
- Navigate to the Settings section.
- Go to the Developer tab.
- Click on your existing OAuth app, or select Create App to register a new one.
Once your app is created, you’ll be redirected to a page displaying your Client ID and Client Secret.
Use these credentials to:
- Generate access and refresh tokens for authenticating with FreJun APIs.
- Subscribe to FreJun webhooks.
Requirements
Section titled “Requirements”- An active Frejun account.
- The following details are required while creating the app.
| Parameter | Description |
|---|---|
| Name | Name of your App |
| Redirect/Callback URI | Users will be redirected to this URL after granting access to your app |
Connecting your application with FreJun
Section titled “Connecting your application with FreJun”- Build the Authorization URL with your application’s
client_idand redirect the user there. It should look like this:
https://product.frejun.com/oauth/authorize/?client_id=<client_id>
- Once the user reaches the Authorization page, they will be prompted to log in to FreJun (if not logged in already) and will be redirected to a consent page where they can Accept or Decline.
- On Accepting, the user will be redirected to the redirect URL
provided while creating the app with
codeandemailof the user attached as a query param:<redirect_url>?code=<authorization_code>&email=<user_email>
- On Declining, the user will be redirected to the redirect URL
provided while creating the app with
codeattached as an empty string:<redirect_url>?code= - The
codeobtained can be used to create Access & Refresh tokens by invoking the create token endpoint.
We also post a message back to the opener of the consent window containing the code and any other parameters that are appended to the redirect_uri, so the opener can directly consume the data without relying only on the redirect flow.
Example (listening for it on the opener side):
window.addEventListener('message', (event) => { if (event.origin !== 'https://product.frejun.com' || !event.data) return; // to make sure the message you are listening to is from the expected origin let eventData = event.data; if(eventData.eventName == "oauth-code") { // Handle the oauth-code event const { code, email, ...otherparams } = eventData.data; }});In the above example:
code: The OAuth authorization code, which can be exchanged for access and refresh tokens.
email: The email address of the user who authorized the app via their Frejun account.
otherparams: Any additional parameters that were included in the original authorization URL.
Email Query Parameter
Section titled “Email Query Parameter”When making API requests using OAuth 2.0 authentication, the email query parameter is required and should be included in all API requests:
GET https://api.frejun.com/api/v2/endpoint?email=user@example.comAuthorization: Bearer <access_token>The email should correspond to the user performing the action.
API Key Authentication
Section titled “API Key Authentication”API Key authentication provides a simpler alternative to OAuth 2.0 for authenticating API requests. This method is ideal for server-to-server integrations or internal applications.
Getting Your API Key
Section titled “Getting Your API Key”To create an API key:
- Log in to your FreJun account at https://product.frejun.com
- Navigate to Settings
- Go to the Developer tab
- Scroll to the bottom of the page to the API Key section
- Click Create to generate a new API key
Using API Key in Requests
Section titled “Using API Key in Requests”To authenticate using an API key, include it in the request header with the Api-Key prefix:
Authorization: Api-Key <your_api_key>Email Query Parameter
Section titled “Email Query Parameter”When making API requests, you should pass the email query parameter to specify which user is performing the action:
GET https://api.frejun.com/api/v2/endpoint?email=user@example.com