authenticate

Authenticate a user to Venly

This function will check if the user is authenticated and if not, ask the user to authenticate.

venlyConnect.flows.authenticate({ windowMode: 'REDIRECT' });
  • If windowMode = 'REDIRECT', the user will be redirected to options.redirectUri with the result after logging in.

  • If windowMode = 'POPUP', the popup will close and the promise resolved when the user finishes the request. No extra options are required.

If you set the redirectUri option, make sure that the SDK and the AuthenticationResult handling is also present on the page you redirect to.

Signature

venlyConnect.flows.authenticate(options?: AuthenticationOptions): Promise<AuthenticationResult>    

Returns

Promise<AuthenticationResult>

Parameters

Parameter

Type

Required

Description

options

False

Provide extra auth options

Examples

// Example 1
// Redirect to the current page
venlyConnect.flows.authenticate({ windowMode: 'REDIRECT' });
// Example 2
// Redirect to https://foo.io
venlyConnect.flows.authenticate({ redirectUri: 'https://foo.io', windowMode: 'REDIRECT'});
// Example 3
// Login using popup
venlyConnect.flows.authenticate({ windowMode: 'POPUP' })
    .then((result: AuthenticationResult) => {
        result
            .authenticated((auth: KeycloakInstance) => {
                alert('logged in: ' + auth.subject);
            })
            .notAuthenticated((auth: KeycloakInstance) => {
                alert('not logged in');
            });
    });

Object Types

pageAuthenticationOptionspageAuthenticationResultpageKeycloakInstance

Last updated