Generating a User Access Tokens
What is a User Access Tokens?
A user access token is a digital token that allows a user to access a protected resource. Arttribute uses user access tokens to authenticate users and authorize them to perform various actions, such as uploading and managing art, creating collections, and attributing art.
To generate a user access token, you can use the Arttribute API. The API will provide you with a token that is valid for a limited period of time. You can then use this token to access Arttribute resources.
Step 1: Request an authentication message
An authentication message is a message that is used to verify your identity and authorize you to access a protected resource. Arttribute uses authentication messages to authenticate users and authorize them to perform certain actions, such as generating user access tokens.
You'll need to request for a authenticate message from the Arttribute platform. This allows us to verify that it is indeed you signing the message.
We've provided code snippets below that demonstrate how to structure your API request.
- NodeJS
- cURL
const axios = require("axios");
let data = {
address: "0x...",
};
axios
.request({
method: "post",
maxBodyLength: Infinity,
url: `https://api.arttribute.io/v1/auth/request`,
headers: {
"Content-Type": "application/json",
},
data: JSON.stringify(data),
})
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
curl --location 'https://api.arttribute.io/v1/auth/request' \
--header 'Content-Type: application/json' \
--data '{
"address": "0x..."
}'
Step 2: Sign the authentication message
To then sign an authentication message, you can use your Web3 wallet or a library such as ethers.js. If you are using a library such as ethers.js, you will need to provide the library with your private key.
Step 3: Request for Access Tokens
Once you have signed an authentication message, you can request user access tokens from Arttribute. To request for a user access token, you can use the Arttribute API.
We've provided code snippets below that demonstrate how to structure your API request.
- NodeJS
- cURL
const axios = require("axios");
// ...request authentication message
let data = {
address: "0x...",
message: "...",
signature: "...",
};
axios
.request({
method: "post",
maxBodyLength: Infinity,
url: `https://api.arttribute.io/v1/auth`,
headers: {
"Content-Type": "application/json",
},
data: JSON.stringify(data),
})
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
curl --location 'https://api.arttribute.io/v1/auth' \
--header 'Content-Type: application/json' \
--data '{
"address": "0x...",
"message": "...",
"signature": "..."
}'
The response contains the access token required to access resources and perform various actions.