@textile/hub > Buckets > getToken
Buckets.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 { Buckets, PrivateKey } from '@textile/hub'
async function example (buckets: Buckets, identity: PrivateKey) {
const token = await buckets.getToken(identity)
return token // already added to `buckets` scope
}