Visual Studio Mobile Center

Identity

Add Identity to your mobile app with either client flow (recommended) or server flow authentication after adding Azure iOS SDK to your mobile app.

Client flow

  1. Install the provider client SDK by following its instructions:
  2. On log in completion with the client SDK, make sure Azure gets the authentication token by adding the following snippets:

for Swift:

Azure Active Directory

let payload: [String: String] = ["access_token": result.tokenCacheStoreItem.accessToken]
azureMobileClient.loginWithProvider("aad", token: payload, completion: completion)

Facebook

let payload: [String: String] = ["access_token": result.token.tokenString]
azureMobileClient.loginWithProvider("facebook", token: payload, completion: completion)

Google

let payload: [String: String] = ["id_token": user.authentication.idToken, "authorization_code": user.serverAuthCode]
azureMobileClient.loginWithProvider("google", token: payload, completion: completion)

Microsoft Acount

let payload: [String: String] = ["authenticationToken": self.liveClient.session.authenticationToken]
azureMobileClient.loginWithProvider("microsoftaccount", token: payload, completion: completion)

Twitter

let payload: [String: String] = ["access_token": session!.authToken, "access_token_secret": session!.authTokenSecret]
azureMobileClient.loginWithProvider("twitter", token: payload, completion: completion)

for Objective-C:

Azure Active Directory

NSDictionary *payload = @{
    @"access_token" : result.tokenCacheStoreItem.accessToken
};
[azureMobileClient loginWithProvider:@"aad" token:payload completion:completion];

Facebook

NSDictionary *payload = @{@"access_token":result.token.tokenString};
[azureMobileClient loginWithProvider:@"facebook" token:payload completion:completion];

Google

NSDictionary *payload = @{
    @"id_token":user.authentication.idToken,
    @"authorization_code":user.serverAuthCode
};
[azureMobileClient loginWithProvider:@"google" token:payload completion:completion];

Microsoft Acount

[azureMobileClient loginWithProvider:@"microsoftaccount" token:@{@"authenticationToken" : self.liveClient.session.authenticationToken} completion:completion];

Twitter

NSDictionary *payload = @{
    @"access_token":session.authToken,
    @"access_token_secret":session.authTokenSecret
};
[azureMobileClient loginWithProvider:@"twitter" token:payload completion:completion];

Server flow

  1. Add the server authentication call to your mobile app to authenticate users.

for Swift:

azureMobileClient.loginWithProvider("{provider}", controller: {nonnull UIViewController}, animated: {BOOL}, completion: completion)

for Objective-C:

[azureMobileClient loginWithProvider:@"{provider}" controller:{nonnull UIViewController} animated:{BOOL} completion:completion];