🔐Authentication


Authentication Methods

  1. Web2: need to provide userId and membershipId.

  2. Web3: need to provide publicAddress and Chain.

membershipId, smartContract Address and Chain needs to be set up in the business portal for authentication to be successful.


Getting Access Token

Endpoint: https://sandbox.chainrewardz.net/auth/v3/login

To integrate Chainrewardz and perform functions for your users, you must call our API to obtain the user's accessToken. This token is required for all functions performed on Chainrewardz. If the user does not exist in our system, a new user will be created based on the userId or publicAddress you provide.

Example Request

Specify whether you are integrating using the Web2 or Web3 method in the request method.

For Web2 Integration: You need to specify the userId (a unique identifier in your system) and membershipId (the membership level defined in your Chainrewardz business portal).

curl --location 'https://sandbox.chainrewardz.net/auth/v3/login' \
--header 'Api-Key: {{api_key}}' \
--header 'Api-Secret: {{api_secret}}' \
--data '{
  "method": "web2",
  "userId": "user12345",
  "membershipId": "membership67890"
}'

For Web3 Integration: You need to specify the publicAddress and the Chain. See our prerequisites section for more information.

curl --location 'https://sandbox.chainrewardz.net/auth/v3/login' \
--header 'Api-Key: {{api_key}}' \
--header 'Api-Secret: {{api_secret}}' \
--data '{
  "method": "web3",
  "publicAddress": "xxxxxx",
  "chain": "ETH"
}'

Example Response

Upon receiving the request, our system will return an accessToken and a refreshToken.

{
  "accessToken": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI1YjFkODhhZi0wZDJjLTQyMzEtOTExMi1lMGMxODA0MjhjZmEiLCJkYXRhIjp7InNpZGUiOiJDVVNUT01FUiIsInR5cGUiOiJBQ0NFU1NfVE9LRU4iLCJ1c2VySWQiOjUsImJ1c2luZXNzSWQiOjMsInJvbGUiOiJjdXN0b21lciIsInBsYXRmb3JtIjoiV0VCMyIsImNoYWluIjoiRVRIIiwicHVibGljQWRkcmVzcyI6IjB4YWM4ZjRDODBmOTg1MzU1NDY1NTZhOWJhYjRhNzk4RDgwNjRFMTBGRSJ9LCJpc3MiOiJodHRwczovL2NoYWlucmV3YXJkei5jb20iLCJleHAiOjE2OTg0NjcwMTl9.PMgcVzEBNMcOrnIsFR-C-NXX0Kq4EVsqVjzLWP2ve-8",
  "refreshToken": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI1YjFkODhhZi0wZDJjLTQyMzEtOTExMi1lMGMxODA0MjhjZmEiLCJkYXRhIjp7InNpZGUiOiJDVVNUT01FUiIsInR5cGUiOiJSRUZSRVNIX1RPS0VOIiwidXNlcklkIjo1LCJidXNpbmVzc0lkIjozLCJyb2xlIjoiY3VzdG9tZXIiLCJwbGF0Zm9ybSI6IldFQjMiLCJjaGFpbiI6IkVUSCIsInB1YmxpY0FkZHJlc3MiOiIweGFjOGY0QzgwZjk4NTM1NTQ2NTU2YTliYWI0YTc5OEQ4MDY0RTEwRkUifSwiaXNzIjoiaHR0cHM6Ly9jaGFpbnJld2FyZHouY29tIiwiZXhwIjozMTcwMjYwNjcwMjB9.JOJDRYCoe7ECYsW4OfmU68XDwBvWgCqJ_4NrFj3iMUE"
}

Last updated