Cobo OAuth vs Cobo Auth
Cobo Auth and Cobo OAuth are two authentication mechanisms. Cobo Auth identifies clients using an API key, while Cobo OAuth identifies clients using an app key and controls access to resources in other organizations through an Org Access Token, along with its permissions and scopes.- If you are developing Cobo Portal Apps for installation and use across different organizations, use Cobo OAuth to authenticate your API requests.
- If you are developing other types of apps to access data and resources within your own organization, use Cobo Auth instead. For more details about Cobo Auth, refer to Authentication with Cobo Auth.
With the WaaS SDK
If you are using the WaaS SDK, you only need to provide the private key of the app key and Org Access Token in the API request as follows:- To learn how to generate an app key, see Generate an app key.
- To learn how to get and use Org Access Tokens, refer to Org Access Tokens.
Without the WaaS SDK
If you don’t use the WaaS SDK, you need to provide all the required authentication information in the request header as follows:- To learn how to generate an app key, see Generate an app key.
- To learn how to get and use Org Access Tokens, refer to Org Access Tokens.
- To learn how to calculate the API signature using your app key, refer to Calculate an API signature.
Generate an app key
An app key is used to authenticate the Cobo Portal App when it makes an API request to the WaaS service. This section introduces three ways to generate an app key. You can also generate app keys using other tools that use the Ed25519 algorithm.- The public key will be used in the manifest file. For more information, refer to Configure the manifest file.
- The private key will be used to authenticate API requests to the WaaS service.
Use Cobo CLI
- Install Cobo CLI if you haven’t. For more information, refer to Install Cobo CLI.
-
In a terminal window, run the following command to generate a key pair.
~/.cobo/.env file by default.
Use OpenSSL
In a terminal window, run the following OpenSSL commands:private.key.pem file, and the public key is saved in the public.key.pem file.
Use a Python library
-
Install the ed25519 Python library.
In a terminal window, run the following command:
-
Generate a key pair.
Import the function from the Python library to generate a key pair as follows:
Calculate an API signature
The following steps introduce how to calculate an API signature.-
First, concatenate a string based on your request as follows:
str_to_sign = {METHOD}|{PATH}|{TIMESTAMP}|{PARAMS}|{BODY}Field Description Example METHODThe HTTP method. GETPATHThe API endpoint. /v2/transactions/transferTIMESTAMPThe current time in Unix timestamp format, measured in milliseconds. This value must be the same as the nonce in the request header. 1718587017026PARAMS(If applicable) The query parameters. chain_id=ETH&limit=10BODY(If applicable) The raw request body in string format. {"name":"Default","wallet_subtype":"Asset","wallet_type":"Custodial"} -
Use the hashlib library to perform SHA-256 hashing twice on the string as follows:
-
Use the private key of your app key to sign the string as follows:
