This tutorial demonstrates how to use the sample repo to set up a login flow that is managed by an external provider, in this case GitHub, using a custom login interface that syncs with Wix’s authentication.
Note: External login with Google and Facebook are fully supported in the Wix-managed login page. When working with Google or Facebook as your external identity provider, only use this externally-managed login flow if you require a custom login interface.
Complete the following steps to log a visitor into your site or app with their GitHub credentials:
Once the member is logged in, you can redirect them to your home page.
Before getting started, make sure you have the following:
getGithubAuth
function.getGithubUserEmail
function.Once you have the member’s email addresses, check if any of them are associated with a Wix member ID.
See the getOrCreateWixMember()
function. Call the queryMembers()
function and filter by the email address collected in step 1:
1
createMember()
function to create one and collect the returned ID.Note that creating members without explicit registration is an admin function. Make sure to use a WixClient and pass an API key that has permission to create members. See the serverWixClient.ts file in the sample project.
Now that you have the Wix member ID, you can request member tokens.
See the getMemberTokensForExternalLogin()
function, which passes the member ID collected in step 2.
1
Note that getting access and refresh tokens is an admin function. Make sure to use the WixClient with your OAuth app that created this visitor, and pass an API key that has permission to create member access tokens, to save the visitor’s activity from before they logged in.
Now you can: