You are viewing Skygear v1 Documentation.Switch to Skygear v0 Documentation

Social Login

Social Login (Facebook, Twitter, etc)

Besides the traditional login method using a password, Skygear also supports authenticating a user with third party services such as Facebook and Twitter, using an auth provider written with cloud code.

You can use the skygear.auth.loginWithProvider method by providing the name of the auth provider, along with the relevant auth data (an object) necessary for the authentication, such as the access token obtained from Facebook.

For example, if you have implemented a Facebook auth provider under the name com.facebook using @skygear.provides('auth', 'com.facebook') in the cloud code, you can log a user in by:

const provider = 'com.facebook';
const authData = {
  'access_token': 'abcdefg',
skygear.auth.loginWithProvider(provider, authData);
  • provider: name of the provider, such as com.facebook or
  • authData: an object that will be passed as a dictionary to the plugin that contains the information necessary to authenticate a user

Note: There is no distinction between signing up and logging in with an auth provider. the Skygear server will create a new user if the principal ID (as returned by the auth provider) does not exist in the database.