Progress will discontinue Telerik Platform on May 10th, 2018. Learn more

Integrating Social Login

Integrating Social Login

The Backend Services iOS SDK provides these methods for registering and authenticating users coming from social authentication providers such as Facebook, Google, and Microsoft Account:

Prerequisites

  • Ensure that you have enabled the provider that you want to use.
  • Obtain an OAuth token for the user. Refer to the social authentication provider's official documentation for more information:

Registration/Login

You register or log in a social user by invoking the respective member of the loginWith<Provider>() method family that belongs to the EVUser class (see the table). The first invocation of the method for a user creates a new user account. Subsequent invocations log in the user to Telerik Platform. See Social Authentication for more information.

Method Name Use for Provider
loginWithFacebook() Facebook
loginWithGoogle() Google
loginWithLiveId() Microsoft Account

All methods take as argument the OAuth token that you obtained from the social authentication provider. For example:

NSString *facebookAccessToken = @"facebook-token";
[EVUser loginWithFacebook:facebookAccessToken block:^(EVUser *user, NSError *error) {
    // the returned user will be authenticated if the login was successful
}];

On success, the method returns an object containing a Telerik Platform access token (not to be mistaken with the OAuth token) that can be used with further Backend Services iOS SDK operations. In that, the loginWith<Provider>() method behaves similarly to the login method.

Developers who have been using the Google Access Token (access_token) parameter to authenticate users are strongly advised to migrate to using the Google ID Token (id_token) parameter instead. Doing so significantly boosts your app security because Telerik Platform can verify the aud claim contained in the token. Note that you also need to enter a Client Id when enabling Google Login, otherwise Telerik Platform skips this verification.

Linking with an OAuth Provider

You link a social user to an existing Telerik Platform user account using a member of the link<Provider>Account() method family that belongs to the EVUser class. The next table lists all available methods:

Method Name Use for Provider
linkFacebookAccount Facebook
linkGoogleAccount Google
linkLiveIdAccount Microsoft Account

The methods take as argument the userId of the Telerik Platform user account that you want to link to, and the acquired OAuth token. For example:

[EVUser linkFacebookAccount:user.id accessToken:@"facebook-access-token" block:^(BOOL success, NSError *error) {
// success indicates whether the linking completed successfully
}];

Developers who have been using the Google Access Token (access_token) parameter to authenticate users are strongly advised to migrate to using the Google ID Token (id_token) parameter instead. Doing so significantly boosts your app security because Telerik Platform can verify the aud claim contained in the token. Note that you also need to enter a Client Id when enabling Google Login, otherwise Telerik Platform skips this verification.

To use these methods, you need to first log the user in or use MasterKey authentication.

If a Telerik Platform user account is already linked to a user from the specified social provider, the method returns an error. To link it to a new social user, first unlink it from the previous one and then reinvoke link<Provider>Account() with the new OAuth token.

Unlinking from an OAuth Provider

You unlink a social user from an existing Telerik Platform user account using a member of the unlink<Provider>Account() method family that belongs to the EVUser class. The next table lists all available methods:

Method Name Use for Provider
unlinkFacebookAccount Facebook
unlinkGoogleAccount Google
unlinkLiveIdAccount Microsoft Account

The methods take as argument the userId of the Telerik Platform user account that you want to unlink. For example:

[EVUser unlinkFacebookAccount:user.id block:^(BOOL success, NSError *error) {
// success indicates whether the unlinking completed successfully
}];

If the user is not linked, you receive an error.

See Also

Friends Sample App

Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.