OAuth2.0 is a HTTP authentication scheme that involves security tokens called Access tokens or Json Web Tokens (JWT). Each request is authenticated with the access token.
The access token is a cryptic string, usually generated by the server in response to a request. The client must send this token in the Authorization header when making requests to protected resources.
The OAuth2.0 authentication is available on the version 1.5.0 and above. The older versions will continue to have the SWT authentication.
Here are the steps on how you can get the JWT from TaxBandits:
Step 1: Retrieve the Authentication Keys
Retrieve the below 3 keys in Console site using your credentials. Navigate to Settings >> API Credentials
-
Client ID
-
Client secret
-
User Token
Note: Do not share the keys with any individual or business.
Step 2: Request the Access Token
To request an Access Token, you need to create a signature (JSON Web Signature) for Authentication. The JWS consists of 3 parts as given below,
Header:
{
"alg": "HS256", /*Algorithm = HS256*/
"typ": "JWT" /*Type = JSON Web Token (JWT)*/
}
Payload:
{
"iss": "968a9c78dae29a29”, /*Issuer: Client ID retrieved from the console*/
"sub": "968a9c78dae29a29", /*Subject: Client ID retrieved from the console*/
"aud": "a574b75f18b24fc09f9039ffb5cb08f3", /*Audience: User Token retrieved from the console*/
"iat": 1516239022 /*Issued at: Number of seconds from Jan 1 1970 00:00:00 (Unix epoch format)*/
}
Signature:
HMACSHA256(
base64UrlEncode(header) + "." +
base64UrlEncode(payload),
siqHfLy59g3UHxrb5gjxg /*Client Secret retrieved from the console*/
)
Combine the Header, payload and signature to create the
JWS.
Sample JWS:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOi
I5NjhhOWM3OGRhZTI5YTI5Iiwic3ViIjoiOTY4YTljNzhkYWUyOWEyOSIsImF1
ZCI6ImE1NzRiNzVmMThiMjRmYzA5ZjkwMzlmZmI1Y2IwOGYzIiwiaWF0IjoxN
TE2MjM5MDIyfQ.HNQznxlPyVt62kyUeVwtk1-uzm1uDWH4NBDLShA6Ac0
Once the JWS is created, then send a request to the Authentication Server for an Access token.
Authentication Server URL:
Sandbox: https://testauth.taxbandits.com/v1/auth
Live: https://auth.taxbandits.com/v1/auth
Once we receive a JWS from the client, TaxBandits will provide the JWT (Access token) to the client in the following format:
Header:
{
"alg": "HS256", /*Algorithm = HS256*/
"typ": "JWT" /*Type = JSON Web Token (JWT)*/
}
Payload:
{
"iss": "testapi.taxbandits.com”,
"sub": "968a9c78dae29a29",
"aud": "a574b75f18b24fc09f9039ffb5cb08f3",
"iat": 1516239022,
"exp": 1516239022 /*Expiry: Number of seconds from Jan 1 1970 00:00:00 for the expiry. The Access Token is valid for 60 minutes*/
}
Signature:
HMACSHA256(
base64UrlEncode(header) + "." +
base64UrlEncode(payload),
siqHfLy59g3UHxrb5gjxg /*Master Secret Key*/
)
Step 3: Use the Access Token to send API Requests
Once you obtain the JWT (Access token), you can determine its expiry by the “ExpiresIn” value in the Response. You will have to use the same JWT along with every API request until the token expires.
Example:
URL:https://api.taxbandits.com/v1.5.0/form1099misc/create
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3
MiOiJ0ZXN0YXBpLnRheGJhbmRpdHMuY29tIiwiYXVkI
joiYTU3NGI3NWYxOGIyNGZjMDlmOTAzOWZmYjVjYjA4ZjMiLCJp
YXQiOjE1OTU5MjAxMjQsImV4cCI6MTU5NTkyNzMyNH0.BIg8764SOhOai9As
3uRSidrF1-B9CxL6D5z4OggcVbs
Content-Type: application/json