Your first request
The purpose of this document is to guide you in making your first request with the INFast API.
Before going any further, make sure you have a pair of ClientId
and ClientSecret
.
If not, you can refer to the quickstart guide.
Retrieve your access token
Requests to the INFast API are authenticated with OAuth2, using an access token (see the reference).
OAuth is a standard. Therefore, there's a high chance that the platform you use for development has an OAuth client library. To configure your library or OAuth2 tool, here are the required parameters:
- Access token URL:
https://api.infast.fr/api/v2/oauth2/token
- Grant type:
Client Credentials
Depending on the tools, you might encounter slightly different names, but the idea is the same 😉
Node.js
Managing OAuth in node.js can be done with client-oauth2, for example.
Here is an example with INFast API:
var ClientOAuth2 = require('client-oauth2');
var infastAuth = new ClientOAuth2({
clientId: '[your_client_id]',
clientSecret: '[your_client_secret]',
accessTokenUri: 'https://api.infast.fr/api/v2/oauth2/token',
scopes: ['write'],
});
infastAuth.credentials.getToken().then(function (response) {
console.log('My accessToken is ' + response.data.access_token);
});
Postman
Here's an example of configuring authentication in Postman:
Curl
To retrieve your access token manually, please refer to the Authentication section.
INFast
During test, you can retrieve your access token directly from INFast in the module Paramètres > Gestion des données > API
of INFast APP. You have to click on Générer un token
.
Make a request
Now that you have your access token, you can authenticate your requests to INFast API.
To authenticate a request, you need to indicate in the Authorization
header (see MDN documentation), with Bearer
as the auth scheme and your access token as the parameter:
Authorization: Bearer [your_access_token]
.
Let's make a first call to the /me
endpoint, which simply returns the current user. As you can see in the reference, it's a simple GET
request, without any parameters.
This endpoint and response are explained in details here.
Curl
curl -L -X GET 'https://api.infast.fr/api/v2/me' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer 9db3a8296b68b7889f2803fc1143610922997adc'
{
"_id": "64370cde00000000009f55d9",
"name": "Julien Durand",
"email": "deve@intia.fr",
"creationDate": "2023-04-12T19:56:04.311Z",
"lastConnectionDate": "2023-10-03T15:08:46.174Z",
"phone": "",
"mobile": "",
"companyName": "Durand dev SA"
}
INFast API documentation
You can test the API directly from the documentation. On each endpoint specification, you can test the api on your data.
Copy your Access Token in the Bearer Token field, send the api request and see response below: