@textile/hub > Filecoin > getToken
Filecoin.getToken() method
Obtain a token for interacting with the remote API. When your app is creating new private-key based users to interact with the API using User Group keys, you must first create a new token for each new user. Tokens do not change after you create them.
Signature:
getToken(identity: Identity): Promise<string>;
Parameters
Parameter | Type | Description |
---|---|---|
identity | Identity | A user identity to use for interacting with APIs. |
Returns:
Promise<string>
Example
import { Filecoin, PrivateKey } from '@textile/hub'
async function example (filecoin: Filecoin, identity: PrivateKey) {
const token = await filecoin.getToken(identity)
return token // already added to `filecoin` scope
}