How to get a bearer token for the MSP portal API

The API uses OAuth 2.0 client_credentials flow for authentication and the OIDC protocol is supported.

Auth-related endpoints can be discovered through https://login.backup.net/.well-known/openid-configuration.

Superusers will need to generate client_id and client_secret to be used for authentication, which can be created in the portal UI.

Obtain client_id and client_secret from the MSP portal (portal.backup.net) via Settings -> Public APIs -> New:

To get an access token use the below API endpoint.

POST https://login.backup.net/connect/token 

Using the body as follows:

Key Value
grant_type client_credentials
client_id <client id obtained from MSP portal>
username <client secret obtained from the MSP portal>

Here is an example of the authentication request:

POST /connect/token HTTP/1.1
Host: login.backup.net
Content-Type: application/x-www-form-urlencoded

client_id=65e25…
&client_secret=8c1156bb068945efa…
&grant_type=client_credentials

Here's an example of the access_token that will be used for further API request created from above:

GET /v1/customers HTTP/1.1
Host: public-api.backup.net
Authorization: Bearer <YOUR ACCESS_TOKEN HERE>

Here's an example bash script that can be used to obtain the Bearer token:

#!/bin/bash
AUTH_URL="https://login.backup.net/connect/token" CLIENT_ID="65e25…" CLIENT_SECRET="8c1156bb068945efa…"
POST_VARS="client_id=${CLIENT_ID}&client_secret=${CLIENT_SECRET}&grant_type=client_credentials" DATA=$(curl -s -d "${POST_VARS}" -X POST $AUTH_URL)
echo ${DATA} | grep -vq access_token && echo "Unable to obtain token. ${DATA}" && exit 1 ACCESS_TOKEN=$(echo ${DATA} | grep -Eo '"access_token":.*?[^\\]",' | awk -F'\"' '{print $4}')
echo ${ACCESS_TOKEN}

For more information, please review the public API documentation via the following:
https://apidoc-public-api.backup.net/swagger-ui-v2/index.html

Have more questions?

Contact us

Was this article helpful?
0 out of 0 found this helpful

Provide feedback for the Documentation team!

Browse this section