Skip to main content

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:


_10
import * as fcl from "@onflow/fcl"
_10
_10
fcl.authenticate(opts)

Or import directly the specific function:


_10
import { authenticate } from "@onflow/fcl"
_10
_10
authenticate(opts)

Usage


_10
import * as fcl from '@onflow/fcl';
_10
fcl
_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
_10
fcl.authenticate();

Parameters

opts (optional)

  • Type: {}
  • Description: Authentication options

Returns

Promise<CurrentUser>

Promise that resolves to the authenticated CurrentUser object or undefined


Rate this page