🔐Auth
Introduction
To request the token, network, and other interface data for deposit and withdrawal services, you need to mount the authorization token to the HTTP request header.
How to use
For the configuration items used in the following examples, please refer to:
📃ConfigurationNormally, you only need one
ETransferCore
instance initialized.If you want to get a new token without any additional business logic.
Installation
📥InstallationUsage
First, init the ETransferCore instance. You can find it in ETransfer SDK Quick Start.
Get the authorization token from the interface, and cache the data.
After getting the token, mount it to the request header and set it to storage.
Example
Method Parameters
Field | Type | Required | Remarks |
---|---|---|---|
pubkey |
|
| user account pubkey |
plain_text |
|
| signed text The signature text can be customized, but it must end with a timestamp. For example: |
signature |
|
| user signature |
version |
|
| Portkey version: |
source |
|
| Wallet type: |
ca_hash |
|
| user ca hash If source= |
chain_id |
|
|
If source= |
managerAddress |
|
| user manager address. |
recaptchaToken |
|
| Recaptcha result. If source= If source= You can directly call the |
Method return value
Field | Type | Remarks |
---|---|---|
token |
| The authorization token. |
Get the authorization token from the storage or interface, and cache the data.
Get data from the cache first. If the data in the storage has expired, it will get a new token from the interface.After getting the token, mount it to the request header and set it to storage.
Example
Method Parameters
Field | Type | Required | Remarks |
---|---|---|---|
pubkey |
|
| user account pubkey |
plainText |
|
| signed text The signature text can be customized, but it must end with a timestamp. For example: |
signature |
|
| user signature |
version |
|
| Portkey version: |
managerAddress |
|
| user manager address |
caHash |
|
| user ca hash
If source= |
chainId |
|
|
|
source |
|
| Wallet type: |
recaptchaToken |
|
| Recaptcha result. If source= If source= You can directly call the |
Method return value
Field | Type | Remarks |
---|---|---|
token | string | The authorization token. |
Get the authorization token from the storage.
The premise is that authorization token has been obtained from the interface before.
If the authorization token is expired, return undefined
.
Example
Method Parameters
Field | Type | Required | Remarks |
---|---|---|---|
walletType | TWalletType |
|
|
managerAddress |
|
| user manager address |
caHash |
|
| user ca hash.
If walletType= |
Method return value
Field | Type | Remarks |
---|---|---|
token |
| The authorization token. |
Only getting authorization tokens from the interface.
Get a new token without any additional business logic.
Example
Method Parameters
Field | Type | Required | Remarks |
---|---|---|---|
pubkey |
|
| user account pubkey |
plain_text |
|
| signed text.
The signature text can be customized, but it must end with a timestamp. For example: |
signature |
|
| user signature |
version |
|
| Portkey version: |
managerAddress |
|
| user manager address |
source |
|
| Wallet type: |
ca_hash |
|
| user ca hash. If source= |
chain_id |
|
|
If source= |
recaptchaToken |
|
| Recaptcha result. If source= If source= You can directly call the |
Method return value
Field | Type | Remarks |
---|---|---|
token_type |
| The return token type, such as |
access_token |
| The return token body. |
expires_in |
| Token expiration time, unit is seconds. |
Last updated