Javascript SDK
The Bloq Javascript SDK enables you to work with Bloq services easily by simplifying authentication.
The Javascript SDK has the following system requirements to install the library:
To install the Bloq Javascript SDK, use either:
npm install --save @bloq/cloud-sdk
OR
yarn add @bloq/cloud-sdk
const { auth, connect } = require('@bloq/cloud-sdk')
const clientId = 'CLIENT_ID'
const clientSecret = 'CLIENT_SECRET'
const connectClient = connect.http({
auth: {
clientId,
clientSecret
},
coin: 'btc',
network: 'mainnet'
})
The auth API helps to simplify the authentication process.
accessToken()
This method returns a promise that resolves in a new created access token using the provided client ID and secret.
The
Access Token
is required to interact with Bloq services. It usually travels in an Authorization header value.Code sample
const { auth } = require('@bloq/cloud-sdk')
const clientId = 'CLIENT_ID'
const clientSecret = 'CLIENT_SECRET'
const client = auth({ clientId, clientSecret })
client.accessToken().then(function (accessToken) {
// Use access token
})
Last modified 1mo ago