This article presents possible use cases and corresponding sample flows for your headless implementation. These flows provide helpful jumping-off points as you plan your headless project's authentication.
This flow guides you through authenticating an existing member using their email and password credentials, and generating a session token for authenticated API calls.
To log in an existing member and generate a session token:
Collect the member's email and password from your login form.
Call Login V 2 with the member's credentials.
Upon successful authentication, use the returned sessionToken to generate member tokens for subsequent authenticated API calls.
Handle potential errors and edge cases:
The Sign On method provides a streamlined approach to authentication that doesn't require traditional password credentials. It automatically creates or updates member accounts as needed during the authentication process. This method is ideal for trusted integrations, and scenarios where you already have verified user information, or for social logins that aren't covered in the Wix-managed login page.
To authenticate a member with Sign On:
Collect the member's email address and profile information (name, phone, etc.) from your interface.
Validate the data:
Call Sign On with the member data.
Handle the response based on the operation result:
sessionToken is returned.Use the returned sessionToken to generate access and refresh tokens for subsequent authenticated API calls.
This flow demonstrates secure password updates for authenticated members. This is specifically for members who know their current password and want to change it.
To change a member's password:
Ensure the member is authenticated with a valid session token or cookies.
Collect the new password from a secure form with proper client-side validation.
Call Change Password with the new password.
Handle the response:
Consider prompting the member to update their password on other devices where they may be logged in.
Handle potential errors:
This flow demonstrates secure member logout with proper session cleanup and optional redirect handling.
To log out a member:
Call Logout with the logout parameters, including a redirect URL if relevant.
The API response includes an HTML page that:
Clean up your implementation state:
Handle logout scenarios: