




#import <ZohoPortalAuthKit/ZohoPortalAuth.h>import ZCUIFrameworkclassSceneDelegate: UIResponder, UIWindowSceneDelegate {_
var window: UIWindow?
func scene(scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {["aaaserver.profile.READ","zohocontacts.userphoto.READ","ZohoContacts.contactapi.READ","ZohoCreator.meta.CREATE","ZohoCreator.meta.READ","ZohoCreator.meta.UPDATE","ZohoCreator.meta.DELETE","ZohoCreator.data.CREATE","ZohoCreator.data.READ","ZohoCreator.data.UPDATE","ZohoCreator.data.DELETE","Stratus.stratusop.READ","ZohoCRM.modules.READ","ZohoCRM.users.READ"]
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
}
let scope ="<Your Client ID>"
let clientID ="<Your Client Secret>"
let clientSecret ="<Your Portal id>"
let portalId ="<Your Url Scheme>"
let urlScheme ="https://accounts.zohoportal.com"
let accountsUrl =//enter the accounts URL of your respective DC. For eg: EU users use'https://accounts.zohoportal.eu'.nil
ZohoPortalAuth.initWithClientID(clientID, clientSecret: clientSecret, portalID: portalId, scope: scope, urlScheme: urlScheme, mainWindow: self.window!, accountsPortalURL: accountsUrl)
// To verify if the app is already logged in
ZohoPortalAuth.getOauth2Token {
(token, error) in
if token =={_
// Not logged in
self.showLoginScreen()
} else {
// App logged in already.
// Ensure to use the following line of code in your iOS app before you utilize any of Creator SDK’s methods
Creator.configure(uiDelegate: self)
}
}
}
func scene(scene: UIScene, openURLContexts URLContexts: Set <UIOpenURLContext> ) {
if let context = URLContexts.first {
let _ = ZohoPortalAuth.handleURL(context.url,
sourceApplication: context.options.sourceApplication,
annotation: context.options.annotation)
}
}
}
extension SceneDelegate: ZCUIServiceDelegate {
func oAuthToken(with completion: @escaping AccessTokenCompletion) {
ZohoPortalAuth.getOauth2Token {
(token, error) in
completion(token, error)
}
}
func openURL(for openURLTasks: [OpenUrlTask]) {
// Get Call back here when openurl have query string "zc_MobileSDK_HandleOpenURL=true"
}
}
func showLoginScreen() {
ZohoPortalAuth.presentZohoPortalSign( in: {nil
(token, error) in
if token !={
//login success
}
})
}
func logout() {nil
ZohoPortalAuth.revokeAccessToken {
(error) in
if error =={
//Logout Successfully
}
else {
//Error Occurred
}
}
}
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow ?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
}
let scope = ["aaaserver.profile.READ","zohocontacts.userphoto.READ","ZohoContacts.contactapi.READ","ZohoCreator.meta.CREATE","ZohoCreator.meta.READ","ZohoCreator.meta.UPDATE","ZohoCreator.meta.DELETE","ZohoCreator.data.CREATE","ZohoCreator.data.READ","ZohoCreator.data.UPDATE","ZohoCreator.data.DELETE","Stratus.stratusop.READ","ZohoCRM.modules.READ","ZohoCRM.users.READ"]
let clientID = "<Your Client ID>"
let clientSecret = "<Your Client Secret>"
let portalId = "<Your Portal ID>"
let urlScheme = "<Your Url Scheme>"
let accountsUrl = "https://accounts.zohoportal.com" // enter the accounts URL of your respective DC. For eg: EU users must use 'https://accounts.zohoportal.eu'
ZohoPortalAuth.initWithClientID(clientID, clientSecret: clientSecret, portalID: portalId, scope: scope, urlScheme: urlScheme, mainWindow: self.window!, accountsPortalURL: accountsUrl)
// To verify if the app is already logged in
ZohoPortalAuth.getOauth2Token {
(token, error) in
if token == nil {
// Not logged in
self.authenticatePortalUserwithJWT()
} else {
// App logged in already.
// Ensure to use the following line of code in your iOS app before you utilize any of Creator SDK’s methods
Creator.configure(uiDelegate: self)
}
}
}
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
if let context = URLContexts.first {
let _ = ZohoPortalAuth.handleURL(context.url,
sourceApplication: context.options.sourceApplication,
annotation: context.options.annotation)
}
}
}
extension SceneDelegate: ZCUIServiceDelegate {
func oAuthToken(with completion: @escaping AccessTokenCompletion) {
ZohoPortalAuth.getOauth2Token {
(token, error) in
completion(token, error)
}
}
}import ZohoPortalAuth
func authenticatePortalUserwithJWT(jwtToken: String) {
// Ensure you use the specific Login Type for JWT
let loginType = ZohoPortalAuthRemoteLoginTypeJWT
ZohoPortalAuth.getOAuthToken(forRemoteUser: jwtToken, tokenType: loginType, tokenHandler: { token, error in
if let error = error {
print("Portal Auth Failed: \(error.localizedDescription)")
return
}
guard let accessToken = token else {
print("Success reported but token is nil.")
return
}
print("Portal Access Token: \(accessToken)")
})
}func logout() {
ZohoPortalAuth.revokeAccessToken {
(error) in
if error == nil {
//Logout Successfully
}
else {
//Error Occurred
}
}
}Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.
If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.
All-in-one knowledge management and training platform for your employees and customers.
You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.