authenticate
Calling this method will authenticate the current user via any wallet that supports FCL. Once called, FCL will initiate communication with the configured discovery.wallet
endpoint which lets the user select a wallet to authenticate with. Once the wallet provider has authenticated the user, FCL will set the values on the current user object for future use and authorization.
This method can only be used in web browsers.
discovery.wallet
value must be set in the configuration before calling this method. See FCL Configuration.
The default discovery endpoint will open an iframe overlay to let the user choose a supported wallet.
authenticate
can also take a service returned from discovery with fcl.authenticate({ service })
.
Import
You can import the entire package and access the function:
_10import * as fcl from "@onflow/fcl"_10_10fcl.authenticate(opts)
Or import directly the specific function:
_10import { authenticate } from "@onflow/fcl"_10_10authenticate(opts)
Usage
_10import * as fcl from '@onflow/fcl';_10fcl_10 .config()_10 .put('accessNode.api', 'https://rest-testnet.onflow.org')_10 .put('discovery.wallet', 'https://fcl-discovery.onflow.org/testnet/authn');_10// anywhere on the page_10fcl.authenticate();
Parameters
opts
(optional)
- Type:
{}
- Description: Authentication options
Returns
Promise that resolves to the authenticated CurrentUser object or undefined