Brine's Docupaper
AboutTrade
  • ABOUT
    • 📒Brine Docupaper
    • 🪙Tokenomics
  • 🗞️Brine Bytes
    • 🧵October Edition
  • TECH
    • 👩‍💻Tech Docupaper
      • 🏨High level architecture
      • 🤔Starkware logic
      • 🌊Transactional flow
        • Off-chain accounts
        • The deposit flow
        • The withdrawal flow
        • The trade flow
        • The transfer flow
        • Full withdrawal
    • 🔌API Documentation
      • 😋Getting started
        • Test connectivity
      • 📈Market
        • 24hr Tickers Price
        • K-line/Candlestick data
        • Orderbook
        • Recent trades
      • ↔️Trading
        • Create order
        • Get order
        • List orders
        • Cancel order
        • List trades
      • 🔐Account
        • Login
        • Profile Information
        • Balance details
        • Profit and loss details
      • 🌏Web-socket stream
        • 🗝️Private web-socket connection
        • 👥Public websocket connection
      • ✨Internal Transfer
        • Create Internal Transfer
        • Get Internal Transfer
        • Check User Existence
        • List Internal Transfers
      • 🧪SDK Reference
        • NodeJS SDK
  • FOR USERS
    • 📒User Docuguide
      • 💻Web App
        • Sign up through Metamask
        • Sign up through Wallet Connect
        • Place a Market Order Trade
        • Place a Limit Order Trade
        • Refer Brine to a Friend
        • Deposit with Metamask
        • Withdraw to Metamask
  • LEGAL
    • ‼️Disclaimer
Powered by GitBook
On this page
  • 1. Nonce Creation
  • 2. Sign The Payload
  • 3.Generate Access Token
  • Refresh Token for Login

Was this helpful?

  1. TECH
  2. API Documentation
  3. Account

Login

PreviousAccountNextProfile Information

Last updated 1 year ago

Was this helpful?

Login endpoint is required to obtain access to all Private🔒 endpoints. The login process involves three steps which are stated below in brief:

  1. Nonce creation: Generate a payload using the /auth/nonce endpoint.

  2. Sign the payload: To sign the payload obtained after accessing the above API, use the helper function.

  3. Generate access token: After generating the signature, the signature & eth address is sent in the /auth/login endpoint.

Please visit and create an account using your wallet before proceeding with the below steps.

1. Nonce Creation

A nonce is a variable that is generated just once and can be used only one time. Generation of a nonce is the first step of the login process. The payload received in this step will be required in the next one.

Endpoint

POST /sapi/v1/auth/nonce/

Request Body

Field
Type
Mandatory

eth_address

STRING

YES

Example:

{
  "eth_address": "Ox"
}

Response

{
  "status": "success",
  "message": "Nonce Acquired",
  "payload": "You’re now signing into Brine Testnet, make sure the origin is https://testnet.brine.finance (Login-code:YG2DHzDpRncwCZAVRUTrVG)
  "
}

2. Sign The Payload

Code snippet

import { signMsg } from '@brine-fi/brine-connector'

const signedMsg = signMsg(message, privateKey) 

3.Generate Access Token

The access token (JWT) is used to authenticate your request for private endpoints. This key allows Brine to ensure that the requests are always coming from the rightful owner. Make use of the signature that was returned in the previous step “Sign The Payload” 👆, along with the ethereum address to receive a JWT Access Token.

Request Body

Field
Type
Mandatory

eth_address

STRING

YES

user_signature

STRING

YES

Example

{
  "eth_address": "Ox",
  "user_signature": "Ox"
}

Response

{
  status: 'success',
  message: 'Login Successful',
  payload: {
    uid: 'IDDAF4F5E3C7',
    signature: ''
  },
  token: {
    refresh: '',
    access: ''
  }
}

Refresh Token for Login

Endpoint

POST /sapi/v1/auth/token/refresh/ 

Request body

{
    "refresh": "eyJndjiFy8gsi0....wJPnQbr9yX4DR" 
} 

Response

{
    "status": "success",
    "message": "",
    "payload": {
        "access": "eybdgyr0iOi....gVbdghy7g_Pn3QCU",
        "refresh": "eyJ0eXAiOi....mVeL25ytndhltJL4"
    }
}

In this step you’d be required to sign the “payload” obtained through the first step i.e., “Nonce Creation” 👆. Use “payload” as variable “data” and call the signMsg function ( have a look at the snippet below ) located in use the . to sign “data” with your private key. A signature that will be required in the third step will be returned at the end of this process.

🔌
🔐
NodeJS SDK
signMsg
Brine's website
NodeJS SDK