Social Login
Skygear allows you to authenticate users using their 3rd party accounts.
Setup
Currently following providers are supported. Please find the setup instructions below:
Login with 3rd party account
Skygear SDK supports two kinds of login flow:
Login with web flow
-
Configure Callback URLs
The callback URL is URL of your application that Skygear redirects to after user is authenticated. You can configure the app scheme by adding following lines into the
Info.plist
and replace${YOUR_APP_SCHEME}
with your URL scheme.<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLName</key> <string>skygear</string> <key>CFBundleURLSchemes</key> <array> <string>${YOUR_APP_SCHEME}</string> </array> </dict> </array>
Skygear SDK will redirect back to your application after user is authenticated through the following link. For production app, please make sure your Skygear portal Allow redirect URLs contains the below link. All URLs will be allowed, if Allow redirect URLs is empty.
${YOUR_APP_SCHEME}://skygeario.com/auth_handler
-
Trigger login with web flow
By calling
loginOAuthProvider
, Skygear SDK will complete the login flow by using browser to login user.
Login with access token
If you obtain the access token from 3rd party provider SDK, you can login to provider as follows:
Link current user with web login flow
Follow steps in Login with web flow and call linkOAuthProvider
instead of loginOAuthProvider
after user login.
Link current user with access token
If you obtain the access token from 3rd party provider SDK, you can link the current user to provider as follows:
Unlink current user with provider
To unlink current user with the provider.
Get the 3rd party provider user profiles
getOAuthProviderProfilesWithCompletionHandler
will return a dictionary of user connected provider profiles. The keys are the providers ID and the values are the profile dictionary. Every time when user login, Skygear will request and update the 3rd party user profile. This is useful to identify if user links with the provider.