@textile/hub > Users > copyAuth
Users.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): Users;
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 Buckets.
import { Buckets, Users } from '@textile/hub'
const usersToBuckets = async (user: Users) => {
const buckets = Buckets.copyAuth(user)
return buckets
}
Example 2
Copy an authenticated Buckets api instance to Users.
import { Buckets, Users } from '@textile/hub'
const bucketsToUsers = async (buckets: Buckets) => {
const user = Users.copyAuth(buckets)
return user
}