Set of methods that allow Eitri shopping apps to login into VTEX with an OAuth provider's account.

Requirements: This feature must be enabled in the Eitri Shopping App native configuration by setting useVtexOAuthService: true in the app configuration file.

Platform availability: Android only. On iOS, isAvailable always returns false.

Methods

  • Verifies if VTEX OAuth is available on the current device.

    Android: Returns true if the user's device has Google Chrome installed, enabled, and supports Google Chrome Auth Tabs, which are required to perform the authentication flow.

    iOS: Always returns false as VTEX OAuth is not supported on iOS.

    Returns Promise<boolean>

    A boolean value indicating whether VTEX OAuth is available on the user's device.

  • Initiates the VTEX authentication flow, redirecting the user to the OAuth provider's account selection screen.

    Platform availability: Android only. On iOS, this method throws an error. Always check isAvailable before calling this method.

    Example:

    const modules = await Eitri.modules();
    const isAvailable = modules?.vtexOAuth?.isAvailable;
    if (!isAvailable) {
    console.log("Vtex OAuth is not available on this device.")
    return
    }

    const available = await isAvailable()
    if (!available) {
    console.log("Vtex OAuth is not available on this device.")
    return
    }

    const login = modules?.vtexOAuth?.login;
    if (!login) return;
    const returnUrl = await login({
    hostDomain: "www.toymania.com.br",
    vtexAccountId: "toymania",
    oAuthProvider: "Google"
    })

    Parameters

    Returns Promise<null | VtexOAuthOutput>

    Object with the authUrl attribute. This attribute represents the url called once the VTEX authentication flow finishes, including authentication tokens as query params.