Our APIs are using OpenID Connect to for authentication.
We use this because it provides a secure method of authentication and builds on the authorization system in OAuth 2.0.
We also provide a personal access token system as well. This better targets server-side script applications that can not easily utilize the interactive login we enforce by OpenID Connect + OAuth 2.0.
The personal access token system is slightly different from other applications in that the token you receive is a refresh token which has a long expiration time (90 days). Read more on how to obtain an access token from a personal access token refresh token.
We recently switched to utilizing a JWT to wrap our token identifiers. This allows several benefits.
To start using our APIs in your product you need to first create an oauth app.
You will need the following pieces of identification information
Also you will need a Redirect URI. This is the URI that the user will be sent to after authorizing your app. We require you to pre-register your redirect URIs as we verify your authorization requests against it to prevent hijacking attempts. Redirect URIs should be a full URI and must be HTTPS except for local development using localhost or .test top-level domains.
This can be done by going to going to the oauth apps page and clicking New.
To perform an authentication request you must first request our Open ID Connect configuration from our discovery endpoint.
If you are using a Open ID Compliant client library you should simply need to perform a discovery against https://account.hubstaff.com
This will request the Open ID Connect Discovery configuration [ https://account.hubstaff.com/.well-known/openid-configuration ]
You should cache this information for 1 week. This configuration includes
To initiate an authorization request, redirect the user to the authorization_endpoint with the following information.
code
for this as we only support the Authorization Code flow.openid
, profile
, email
, and scopes for access within the specific API.The user will be presented with an authorization screen by us showing them what data you are wanting access to. Once they authorize the request we will send them to the redirect_uri with the code and state
Once you receive a success response to your redirect_uri you use the code
in that response to exchange for an access token.
This is done by making a POST to the token_endpoint to retrieve the access_token and refresh_token.
authorization_code
for thisOn a successful response you will receive
bearer
.To make an API request using the access_token you just need to send it in the Authorization header like this
Authorization: Bearer e2f8c8e136c73b1e909bb1021b3b4c29
To refresh the access_token make a refresh grant request to the token_endpoint.
This is done by making a POST to the token_endpoint .
refresh_token
for thisOn a successful response you will receive
bearer
.Personal access tokens can be managed on the personal access token page.
When you create a personal access token you will receive a refresh token identifier. Before connecting to our API, you first need to exchange that for an access token. Exchanging the token is done by calling the standard OAuth 2.0 token endpoint and using the refresh_token grant_type.
This is done by making a POST to the token_endpoint .
Note that this is nearly identical to the standard refresh_token call
refresh_token
for thisOn a successful response you will receive
bearer
.