Web2
This is the traditional way you log on to an application. You give a username and a password. Server checks that the provided credentials exist and return to you a JWT.
sequenceDiagram
participant C as Client
participant S as Server
C->>S: Here you have my credentials: Username and password
activate S
S-->>C: All seems correct here you have a JWT
deactivate S
Code example
Using username and password
// Using axios
// ES6 import
import axios from "axios";
// CommonJS
const axios = require("axios");
// Preparing body
const body = {
web3: false,
user: 'username',
password: 'somepassword'
};
// Sending request to server
axios.post('http://localhost:3000/auth/sign-in', body)
.then(response => {
// Then you have your access token
const {access_token} = response.data;
});
// Using axios
import axios from "axios";
// Preparing body
const body = {
web3: false,
user: 'username',
password: 'somepassword'
};
// Sending request to server
axios.post('http://localhost:3000/auth/sign-in', body)
.then(response => {
// Then you have your access token
const {access_token} = response.data;
});
Using email and password
// Using axios
// ES6 import
import axios from "axios";
// CommonJS
const axios = require("axios");
// Preparing body
const body = {
web3: false,
user: 'username@example.com',
password: 'somepassword'
};
// Sending request to server
axios.post('http://localhost:3000/auth/sign-in', body)
.then(response => {
// Then you have your access token
const {access_token} = response.data;
});
// Using axios
import axios from "axios";
// Preparing body
const body = {
web3: false,
user: 'username@example.com',
password: 'somepassword'
};
// Sending request to server
axios.post('http://localhost:3000/auth/sign-in', body)
.then(response => {
// Then you have your access token
const {access_token} = response.data;
});