The Fusioo API uses the OAuth 2 protocol for authentication.
The OAuth 2 specification is a flexible authorization framework that describes different methods in which a client application can acquire an access token. Once acquired, you (as a developer) can use such token to authenticate a request to an API endpoint. The Access Token represents the user’s authorization for the client application to access their data on their behalf.
This section will outline how to use OAuth with Fusioo. For more information about OAuth feel free to also take a look at the official OAuth spec.
Fusioo supports three different authentication flows, depending on the type of application you are building:
To get started, you need to register an application.
In your application the user should be redirected to https://connect.fusioo.com/oauth/authorize
with the following query string parameters:
Parameter | Description |
---|---|
response_type | required - Should be set to code |
redirect_uri | required - The URI where the user will be redirected on success or error. This must match the Redirect URI specified in your application settings. |
client_id | required - The Client ID uniquely identifies the application making the request. |
state |
optional - An arbitrary value used by the application to maintain state between the request and callback. The parameter should be used for preventing cross-site request forgery. |
Full URL example: https://connect.fusioo.com/oauth/authorize?response_type=code&redirect_uri=YOUR_URL&client_id=YOUR_APPLICATION_ID&state=RANDOM_STRING
redirect_uri
parameter.
An additional descriptive parameter (error_description) will be added to let you know that the user denied access.
http://YOUR_URL?error=access_denied&error_description=Access+denied
Parameter | Description |
---|---|
code | The code which needs to be exchanged for a token via the token exchange endpoint. |
state | The state parameter that was sent with the authorizing request, if any. |
Simply make a POST
to https://connect.fusioo.com/oauth/token
passing the following parameters:
Parameter | Description |
---|---|
grant_type | required - Should be set to authorization_code |
code | required - The code received in the previous response. |
redirect_uri | required - The URI to redirect to on success or error. This must match the Redirect URL specified in the application settings. |
client_id | required - The Client ID uniquely identifies the application making the request. |
client_secret | required - The Client Secret belonging to your application, found in the integrations page. |
Parameter | Description |
---|---|
access_token | The token to use in future requests against the API |
expires_in | The number of seconds the access token is valid, usually 3600 (one hour) |
token_type | The type of token, in this case, bearer |
refresh_token | The refresh token is used to get a new access token without needing to redirect or reauthorize the user |
POST
request to https://connect.fusioo.com/oauth/token
passing the following parameters:
Parameter | Description |
---|---|
grant_type | required - Should be set to refresh_token |
refresh_token | required - The Refresh Token received with the previous Access Token request. |
client_id | required - The Client ID uniquely identifies the application making the request. |
client_secret | required - The Client Secret belonging to your application, found in the integrations page. |
Parameter | Description |
---|---|
access_token | The new access token to use in future requests against the API |
expires_in | The number of seconds the access token is valid, usually 3600 (one hour) |
token_type | The type of token, in this case, bearer |
refresh_token | The new refresh token, which is used to get a new access token without the need to redirect or reauthorize the user |
The implicit grant is similar to the Authorization Code Grant flow, with some differences:
response_type
parameter must be set to token
The flow is performed in 2 steps:
Redirect the user to https://connect.fusioo.com/oauth/authorize
with the following query string parameters:
Parameter | Description |
---|---|
response_type | required - Should be set to token |
redirect_uri | required - The URI to redirect to on success or error. This must match the Redirect URL specified in the application settings. |
client_id | required - The Client ID uniquely identifies the application making the request. |
state |
optional - An arbitrary value used by the application to maintain state between the request and callback. The parameter should be used for preventing cross-site request forgery. |
The client secret is not included here. Most of the use cases for implicit grants are mobile or desktop apps, where the secret cannot be protected.
Full URL example: https://connect.fusioo.com/oauth/authorize?response_type=token&redirect_uri=YOUR_URL&client_id=YOUR_APPLICATION_ID&state=RANDOM_STRING
When the user authorizes the application, you will receive a redirect back from the authorization endpoint with the following parameters embedded in the fragment portion (the part following the #) of the URL:
Parameter | Description |
---|---|
access_token | This token can then be used to access the API, in this case typically using CORS. |
token_type | Will be set to bearer |
expires_in | The number of seconds the token is valid, usually 3600 (one hour) |
state | The state parameter that was sent with the authorizing request. |
Full URL example: https://YOUR_URL#access_token=ACCESS_TOKEN&token_type=bearer&expires_in=3600&state=RANDOM_STRING
This flow is suitable for applications that can ask end-users for their email and password. The user credentials are used in a single request and are exchanged for an access token.
In this flow there are no redirects to the Fusioo authorization page. The user provides the email and password directly to the application.
To use the password grant type, simply make a POST
to https://connect.fusioo.com/oauth/token
with the following body parameters to the authorization server:
Parameter | Description |
---|---|
grant_type | required - Should be set to password . |
username | required - The user's email |
password | required - The user's password |
client_id | required - The Client ID uniquely identifies the application making the request. |
client_secret | required - The Client Secret belonging to your application, found in the integrations page. |
In the response, you will receive an Access Token which you can use to make calls to the API.
Parameter | Description |
---|---|
access_token | This token can then be used to access the API. |
token_type | Will be set to bearer |
expires_in | The number of seconds the token is valid, usually 3600 (one hour) |
This flow is suitable for internal API applications which will be integrated with other applications (machine-to-machine authentication). The Client Id and Client Secret are used as credentials.
Note: The Credentials Grant can be used only when your application is set to Private.
To use the credentials grant type, simply make a POST
to https://connect.fusioo.com/oauth/token
with the following body parameters to the authorization server:
Parameter | Description |
---|---|
grant_type | required - Should be set to client_credentials |
client_id | required - The Client ID uniquely identifies the application making the request. |
client_secret | required - The Client Secret belonging to your application, found in the integrations page. |
Note: The content type for this request should be set to application/x-www-form-urlencoded.
In the response, you will receive an Access Token (valid for 10 years) which you can use to make calls to the API.
Parameter | Description |
---|---|
access_token | This token can then be used to access the API. |
token_type | Will be set to bearer |
expires_in | The number of seconds the token is valid. For the credentials grant, it is set to 315359999 (10 years) |
refresh_token | The refresh token is used to get a new access token. |
Type above and the results will be displayed here.