Auth

Auth (/public-api/auth/)

Generates an access token using which you can access Hubler's public APIs. Ensure that you provide valid credentials to get an access token.

For generating the token, you must pass the “accountid” and a “Secret” of your own in the payload, these are the mandatory parameters for the API. For generating the user-specific token, you need to pass the user_id in the payload, which is an optional parameter.

To get an access token, make a POST request to the authorization endpoint.

Request Parameters

The access token request will contain the following parameters.

Attribute
Type
Required
Example
Description

account

ObjectId

Required

5723073937d63a18396a 1bae

Hubler Account id is used to authenticate the user for this request.

secret

String

Required

hubble

A secret value is passed to authenticate and receive the authorization token.

user_id

ObjectId

Optional

The user id is passed for authentication, and it is optional.

Example Payload

The following example shows an access token request

If the request is valid, the server returns the HTTP 200 OK status code and the success message.

Successful Response

Code
Message
Description

200

OK

If the request succeeds, the server returns the HTTP 200 and code along with the success message.

The response with an access token should contain the following properties: status and token.

For example, a successful access token response may look like the following:

Unsuccessful Response

If the access token request is invalid, such as the redirect URL didn’t match the one used during authorization, then the server needs to return an error response.

Error responses are returned with an HTTP 400 status code (unless specified otherwise), with error and error_description parameters.

The error parameter will always be one of the values listed below.

  • The entire error response is returned as a JSON string, similar to the successful response. Below is an example of an error response.

Error Response

Sample Error Response

The following table contains the other possible error response of this API.

Error Type
Error Message

Validation

The request is missing an "accountid" so the server can’t proceed with the request. This may also be returned if the request includes an unsupported parameter or repeats a parameter

Validation

The request is missing a "secret" so the server can’t proceed with the request. This may also be returned if the request includes an unsupported parameter or repeats a parameter.

Validation

User authentication failed, such as if the request contains an invalid account or secret. Send an HTTP 401 response in this case.

Validation

The account must be object id.

Validation

The secret must be str

Validation

The account not found!

Error

Error in validating account while generating token!

Error

Error in preparing token payload!

Error

Error in encoding token!

Error

Error in storing secret!

Error

Error in storing secret!

Error

Error in generating auth token!

Example cURL

Last updated