ZohoAuth

@interface ZohoAuth : NSObject

ZohoAuth is a hollistic SDK which provides easy to use methods. Using these methods you can achieve Zoho sign-in integration with your iOS Mobile Application.

  • This method will initialize the parameters which are required by the SSOKit. Call this method at App Launch.

    Declaration

    Objective-C

    + (void)initWithClientID:(NSString *)clientID
                ClientSecret:(NSString *)clientSecret
                       Scope:(NSArray *)scopearray
                   URLScheme:(NSString *)urlScheme
                  MainWindow:(id)mainWindow
                 AccountsURL:(NSString *)accountsURL;

    Swift

    class func initWithClientID(_ clientID: String!, clientSecret: String!, scope scopearray: [Any]!, urlScheme: String!, mainWindow: Any!, accountsURL: String!)

    Parameters

    clientID

    It is a unique identifier you receive when you register your application with Zoho

    clientSecret

     A unique key generated when you register your application with Zoho. This must be kept confidential.

    scopearray

    The API scopes requested by the app, represented in an array of |NSString|s. The default value is |@[aaaserver.profile.READ,zohocontacts.userphoto.READ]|.(Get the list of scopes required for your app from the respective service teams. Each Scope String should follow the proper syntax. -> ‘servicename’.‘scopename’.‘operation type’ Example: AaaServer.profile.READ.

    urlScheme

    Your App’s URL Scheme.(!Please WhiteList the URL Scheme ZOA!)

    mainWindow

    A UIWindow instance is required for presenting SFSafariViewController/AccountChooserViewController.

    accountsURL

    This is the Enum of your build type.

  • This method will initialize the parameters which are required by the SSOKit. Call this method at App Launch in Extensions and iWatch. (Note: Add your main app’s bundle id in your extensions info.plist for SSOKIT_MAIN_APP_BUNDLE_ID key)

    Declaration

    Objective-C

    + (void)initExtensionWithClientID:(NSString *)clientID
                         ClientSecret:(NSString *)clientSecret
                                Scope:(NSArray *)scopearray
                            URLScheme:(NSString *)urlScheme
                          AccountsURL:(NSString *)accountsURL;

    Swift

    class func initExtension(withClientID clientID: String!, clientSecret: String!, scope scopearray: [Any]!, urlScheme: String!, accountsURL: String!)

    Parameters

    clientID

    It is a unique identifier you receive when you register your application with Zoho

    clientSecret

    A unique key generated when you register your application with Zoho. This must be kept confidential.

    scopearray

    The API scopes requested by the app, represented in an array of |NSString|s. The default value is |@[aaaserver.profile.READ,zohocontacts.userphoto.READ]|.(Get the list of scopes required for your app from the respective service teams. Each Scope String should follow the proper syntax. -> ‘servicename’.‘scopename’.‘operation type’ Example: AaaServer.profile.READ.

    urlScheme

    Your App’s URL Scheme.(!Please WhiteList the URL Scheme ZOA!)

    accountsURL

    This is the Enum of your build type.

  • Method to clear the keychain items stored by SSOKit which would be persistant even after uninstalling the app. (Call this method if it is going to be your apps firt time launch. Not requried post iOS 10.3)

    Declaration

    Objective-C

    + (void)clearZohoAuthDetailsForFirstLaunch;

    Swift

    class func clearDetailsForFirstLaunch()
  • Method to handle OAuth redirection via URL Scheme. This method should be called from your |UIApplicationDelegate|‘s |application:openURL:sourceApplication:annotation|. Returns |YES| if |SSOKit handled this URL.

    Declaration

    Objective-C

    + (BOOL)handleURL:(id)url
        sourceApplication:(id)sourceApplication
               annotation:(id)annotation;

    Swift

    class func handleURL(_ url: Any!, sourceApplication: Any!, annotation: Any!) -> Bool

    Parameters

    url

    url opened.

    sourceApplication

    The application which opened this app.

    annotation

    annotation object.

    Return Value

    YES if SSOKit handled this URL.

  • Method for letting us know that your app has an App Extension, so that we will place the respective data in the keychain within the specified app group. Call this method in App Delegate launch after the above initializeWithClientID method. This should be called before you call clearSSODetailsForFirstLaunch method.

    Declaration

    Objective-C

    + (void)setHavingAppExtensionWithAppGroup:(NSString *)appGroup;

    Swift

    class func setHavingAppExtensionWithAppGroup(_ appGroup: String!)

    Parameters

    appGroup

    appgroup string in which you want the keychain data to be available.

  • Gets the access token. In case the access token has expired or is about to expire, this method get a new token.

    Declaration

    Objective-C

    + (void)getOauth2Token:(ZohoAuthAccessTokenHandler)tokenBlock;

    Swift

    class func getOauth2Token(_ tokenBlock: ZohoAuthAccessTokenHandler!)

    Parameters

    tokenBlock

    callback in which you will get the required access token.

  • Method to get the OAuth details which will be required by the Watch App to refresh the expired access token.

    Declaration

    Objective-C

    + (NSDictionary *)giveOAuthDetailsForWatchApp;

    Swift

    class func giveOAuthDetailsForWatchApp() -> [AnyHashable : Any]!

    Return Value

    dictionary containing all the details which is required to fetch a new access token.

  • Method to set the OAuth details obtained from iPhone to the keychain of watch app.

    Declaration

    Objective-C

    + (void)setOAuthDeteailsInKeychainForWatchApp:(NSDictionary *)OAuthDetails;

    Swift

    class func setOAuthDeteailsInKeychainForWatchApp(_ OAuthDetails: [AnyHashable : Any]!)

    Parameters

    oauthDetails

    dictionary containing the details required to fetch new access token.

  • This method presents the initial viewcontroller - (SFSafariViewController for Sign-in/ SSOUserAccountsTableViewController for SSO Account Chooser).

    Declaration

    Objective-C

    + (void)presentZohoSignIn:(ZohoAuthSignInHandler)signinBlock;

    Swift

    class func presentZohoSign(in signinBlock: ZohoAuthSignInHandler!)

    Parameters

    signinBlock

    handler block.

  • This is a special method. If you are handling sign-in, you will send us a SAML response which we will process and generate an access token for you. Use this method to set a callback handler for us to send the access token back to you.

    Declaration

    Objective-C

    + (void)setSignInCallback:(ZohoAuthSignInHandler)signinBlock;

    Swift

    class func setSignInCallback(_ signinBlock: ZohoAuthSignInHandler!)

    Parameters

    signinBlock

    handler block.

  • This method presents the initial viewcontroller with custom parameters for Sign-in page - (SFSafariViewController for Sign in/ SSOUserAccountsTableViewController for SSO Account Chooser).

    Declaration

    Objective-C

    + (void)presentZohoSignInHavingCustomParams:(NSString *)urlParams
                                  signinHanlder:(ZohoAuthSignInHandler)signinBlock;

    Swift

    class func presentZohoSign(inHavingCustomParams urlParams: String!, signinHanlder signinBlock: ZohoAuthSignInHandler!)

    Parameters

    urlParams

    custom urlparams to be passed to the sign-in page.

    signinBlock

    handler block.

  • Call this method at Logout. This will revoke the access token from the server and clears the keychain items stored by SSOKit.

    Declaration

    Objective-C

    + (void)revokeAccessToken:(ZohoAuthRevokeAccessTokenHandler)revoke;

    Swift

    class func revokeAccessToken(_ revoke: ZohoAuthRevokeAccessTokenHandler!)

    Parameters

    revoke

    handler block.

  • Call this method to update your profile photo.

    Declaration

    Objective-C

    + (void)updatePhoto:(id)image uploadHandler:(ZohoAuthUploadHandler)uploadBlock;

    Swift

    class func updatePhoto(_ image: Any!, uploadHandler uploadBlock: ZohoAuthUploadHandler!)

    Parameters

    image

    UIImage object.

    uploadBlock

    handler block.

  • Call this method to get the api domain.

    Declaration

    Objective-C

    + (NSString *)getAPIDomain;

    Swift

    class func getAPIDomain() -> String!

    Return Value

    api domain of current user.