@textile/hub > Filecoin > copyAuth
Filecoin.copyAuth() method
Copies the full scope and authentication from one API instance to this one. This will copy any existing authentication and authorization info, including:
Information created withKeyInfo and withUserAuth.
Any token generated from getToken or getTokenChallenge.
If you scoped the instance to a specific thread using withThread
Signature:
static copyAuth(auth: GrpcAuthentication, options?: CopyAuthOptions): Filecoin;
Parameters
Parameter | Type | Description |
---|---|---|
auth | GrpcAuthentication | any authenticated API class such as Users or Buckets. |
options | CopyAuthOptions |
Returns:
Example 1
Copy an authenticated Users api instance to Filecoin.
import { Filecoin, Users } from '@textile/hub'
const usersToFilecoin = async (user: Users) => {
const filecoin = Filecoin.copyAuth(user)
return filecoin
}
Example 2
Copy an authenticated Filecoin api instance to Users.
import { Filecoin, Users } from '@textile/hub'
const filecoinToUsers = async (filecoin: Filecoin) => {
const user = Users.copyAuth(filecoin)
return user
}