{"_id":"54738fa71a20c70800e189c1","category":{"_id":"546b90a0b47b5d1400109ee2","project":"545137a814af501a00b50cf9","pages":["54738f761a20c70800e189bc","54738f7f1a20c70800e189be","54738f91007eb108007e041d","54738fa71a20c70800e189c1","54738fbd007eb108007e041f","54739056007eb108007e0421"],"version":"545137a814af501a00b50cfc","__v":6,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-11-18T18:32:00.749Z","from_sync":false,"order":6,"slug":"sdks","title":"SDKs"},"project":"545137a814af501a00b50cf9","parentDoc":null,"user":"5433099f9a2b451a00ad4531","version":{"_id":"545137a814af501a00b50cfc","project":"545137a814af501a00b50cf9","__v":11,"createdAt":"2014-10-29T18:53:28.525Z","releaseDate":"2014-10-29T18:53:28.525Z","categories":["545137a814af501a00b50cfd","545138eaa66f020800dbab4a","546b9072b47b5d1400109edf","546b9082b47b5d1400109ee0","546b9088b47b5d1400109ee1","546b909462515a14007ebc43","546b90a0b47b5d1400109ee2","546ced235884600e007a92f6","5481008eea7fd40b00cd7c2b","573b9d83ee2b3b220042291f","57be1efa15efc70e006a5f99"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":4,"updates":["555638be26e9bc0d0044ea88"],"next":{"pages":[],"description":""},"createdAt":"2014-11-24T20:05:59.708Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"basic_auth":false,"results":{"codes":[]},"try":true,"auth":"never","params":[],"url":""},"isReference":false,"order":3,"body":"The iOS SDK enables you to perform Yammer authentication to obtain an OAuth 2 token and then read/write to the Yammer REST API using this token. The SDK and a sample app using the SDK are available at: https://github.com/yammer/ios-yammer-sdk.\n\n\n**Setup**\n\nRegister Custom Redirect URI\n\nThe first step is to register a new Yammer app that represents your iOS app. During registration, set the Redirect URI to a custom URI Scheme i.e. AppName://your.custom.uri. Make sure the Scheme name (in this case AppName) is unique to your company and iOS app. Here’s an example for an iOS app named Move to Locker :\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/jbVPMV0Q0uKL0JguEV10_LoginWithYammer.png\",\n        \"LoginWithYammer.png\",\n        \"372\",\n        \"89\",\n        \"#343434\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nSpecify URL Scheme\n\nDuring the login process, users will be directed to the mobile Safari web browser to complete the OAuth handshake. In order for the browser to be able to switch back to your iOS app after the handshake is done, the custom URL Scheme from above should be registered in the iOS application.\n\nHere’s how you do that: In the XCode Project Navigator of your iOS app, expand the Supporting Files group and open your app’s plist file. Add a new row by going to the menu and clicking Editor > Add Item. Select URL Types. Expand the URL Types key, expand Item 0, and add a new item: URL Schemes. For the Move to Locker app, this looks like:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/QUeQuyWES8G9p2ITRfxK_URLScheme.png\",\n        \"URLScheme.png\",\n        \"456\",\n        \"96\",\n        \"#997f62\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nIntegrate the SDK into your Project\n\nThe SDK has been packaged as a Cocoapod. You can include the SDK in your project by installing Cocoapods, creating a Podfile and specifying that you want to include the YammerSDK pod. The first step is to install Cocoapods from the terminal by typing: sudo gem install cocoapods\n\nThen create a file called Podfile in your project's directory, open it with a text editor and add the following lines:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"platform :ios, '7.0'\\n\\ntarget 'YOURTARGET' do\\n\\npod 'YammerSDK'\\n\\nend\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\nNext type pod install from the command line in your project's folder. From now on you should open your project from the .xcworkspace file that Cocoapods has created.\n\nConfigure Yammer OAuth service\n\nUpdate the following lines in the sample application's YMAppDelegate.m file with your client ID, secret and redirect URI from Yammer client application\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (void)configureLoginClient\\n{\\n    /* Add your client ID here */\\n    [[YMLoginClient sharedInstance] setAppClientID::::at:::\\\"APP CLIENT ID\\\"];\\n\\n    /* Add your client secret here */\\n    [[YMLoginClient sharedInstance] setAppClientSecret:@\\\"APP CLIENT SECRET\\\"];\\n\\n    /* Add your authorization redirect URI here */\\n    [[YMLoginClient sharedInstance] setAuthRedirectURI:@\\\"AUTH REDIRECT URI\\\"];\\n}\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\nIf you plan to use the SDK in your own app make sure you add these lines into your application's app delegate in the application:didFinishLaunchingWithOptions: method.\n\n\n**Initiate User Login**\n\nTypically, a “Login with Yammer” button on your app’s login view will initiate OAuth 2 based user authentication.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/v4QaerdKSsuUFe0J6zYx_LoginWithYammer.png\",\n        \"LoginWithYammer.png\",\n        \"372\",\n        \"89\",\n        \"#343434\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nLook at the “login” method in YMSampleHomeViewController.m to see how to initiate the OAuth login.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (IBAction)login:(id)sender\\n{\\n    [[YMLoginClient sharedInstance] startLogin];\\n}\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\nThe “startLogin” method in YMLoginClient.m launches the iOS Safari web browser to bring up the OAuth login page where the user enters their Yammer credentials. After they enter their credentials, they are presented with an app authorization page for your iOS app with an “Allow” button.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (void)startLogin\\n{\\n    NSAssert(self.appClientID, @\\\"App client ID cannot be nil\\\");\\n    NSAssert(self.appClientSecret, @\\\"App client secret cannot be nil\\\");\\n    NSAssert(self.authRedirectURI, @\\\"Redirect URI cannot be nil\\\");\\n    \\n    NSString *stateParam = [self uniqueIdentifier];\\n    [[PDKeychainBindings sharedKeychainBindings] setObject:stateParam forKey:YMKeychainStateKey];\\n    \\n    NSDictionary *params = @{@\\\"client_id\\\": self.appClientID,\\n                             @\\\"redirect_uri\\\": self.authRedirectURI,\\n                             @\\\"state\\\": stateParam};\\n\\n    NSString *baseUrlString = [NSString stringWithFormat:@\\\"%@/dialog/oauth\\\", YMBaseURL];\\n    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:baseUrlString]];\\n\\n    AFHTTPRequestSerializer * requestSerializer = [[AFHTTPRequestSerializer alloc] init];\\n    NSError *error;\\n    NSURLRequest *serializedRequest = [requestSerializer requestBySerializingRequest:request withParameters:params error:&error];\\n\\n    if (error) {\\n        NSLog(@\\\"Failed to serialize request: %@\\\", error);\\n    }\\n\\n    // Yammer SDK: This will launch mobile (iOS) Safari and begin the two-step login process.\\n    // The app delegate will intercept the callback from the login page.  See app delegate for method call.\\n    [[UIApplication sharedApplication] openURL:serializedRequest.URL];\\n}\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n\n**Handle Redirect URI**\n\nOnce the user authorizes your iOS app by clicking on the “Allow” button, the browser redirects to the custom URL that you specified above. In order for the user to re-enter your app functionality, your app delegate should handle this redirect.\n\nFor details on handling the redirect, open the sample app’s YMAppDelegate.m file and look at the following method:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {\\n\\n    // If we arrive here it means the login was successful, so now let's get the authToken to be used on all subsequent requests\\n-[YMLoginCClient handleLoginRedirectFromUrl:sourceApplication:]\\n    if ([[YMLoginClient sharedInstance] handleLoginRedirectFromUrl:url sourceApplication:sourceApplication])\\n        return YES;\\n\\n    // URL was not a match, or came from an application other than Safari\\n    return NO;\\n}\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\nNote: Once the server sees that a user has clicked the Allow button, future login requests do not display the page with the Allow button. This is a one time occurance for each unique user/iOS app combination. Subsequent login attempts will return directly to the iOS app without the Allow page. You can manually Revoke Access to your app by going to https://www.yammer.com/account/applications.\n\n\n**Obtain User Auth Token**\n\nThe “handleLoginRedirectFromUrl” method in YMLoginClient.m, called on handling the redirect, runs a few checks and then calls a method to obtain a user auth token from Yammer. The auth token is stored in the keychain. All subsequent calls to the Yammer API use this authToken as the key into the system. Here’s the method in YMLoginClient.m for obtaining the auth token.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (void)obtainAuthTokenForCode:(NSString *)code\\n{\\n    // Query params\\n    NSDictionary *params = @{\\n                             @\\\"client_id\\\"       : self.appClientID,\\n                             @\\\"client_secret\\\"   : self.appClientSecret,\\n                             @\\\"code\\\"            : code\\n                             };\\n\\n    // Yammer SDK: Note that once we have the authToken, we use a different constructor to create the client:\\n    // - (id)initWithAuthToken:(NSString *)authToken.\\n    // But we don't have the authToken yet, so we use this:\\n    YMAPIClient *client = [[YMAPIClient alloc] init];\\n\\n    __weak typeof(self) weakSelf = self;\\n\\n    [client postPath:@\\\"/oauth2/access_token.json\\\"\\n          parameters:params\\n             success:^(id responseObject) {\\n                 \\n                 NSDictionary *jsonDict = (NSDictionary *) responseObject;\\n                 NSDictionary *access_token = jsonDict[@\\\"access_token\\\"];\\n                 NSString *authToken = access_token[@\\\"token\\\"];\\n                 \\n                 // For debugging purposes only\\n                 NSLog(@\\\"Yammer Login JSON: %@\\\", responseObject);\\n                 NSLog(@\\\"authToken: %@\\\", authToken);\\n                 \\n                 // Save the authToken in the KeyChain\\n                 [weakSelf storeAuthTokenInKeychain:authToken];\\n                 \\n                 [weakSelf.delegate loginClient:weakSelf didCompleteWithAuthToken:authToken];\\n                 [[NSNotificationCenter defaultCenter] postNotificationName:YMYammerSDKLoginDidCompleteNotification object:weakSelf userInfo:@{YMYammerSDKAuthTokenUserInfoKey: authToken}];\\n             }\\n             failure:^(NSInteger statusCode, NSError *error) {\\n                 NSMutableDictionary *userInfo = [@{NSLocalizedDescriptionKey: @\\\"Unable to retrieve authentication token from code\\\"} mutableCopy];\\n                 if (error) {\\n                     userInfo[NSUnderlyingErrorKey] = error;\\n                     userInfo[NSLocalizedFailureReasonErrorKey] = [error localizedDescription];\\n                 }\\n                 \\n                 NSError *newError = [NSError errorWithDomain:YMYammerSDKErrorDomain code:YMYammerSDKLoginObtainAuthTokenError userInfo:userInfo];\\n                 \\n                 [weakSelf.delegate loginClient:weakSelf didFailWithError:newError];\\n                 [[NSNotificationCenter defaultCenter] postNotificationName:YMYammerSDKLoginDidFailNotification object:weakSelf userInfo:@{YMYammerSDKErrorUserInfoKey: newError}];\\n             }\\n     ];\\n}\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\nNote: The Safari browser in iOS will hold on to the auth token in a cookie in the browser. So if you have already logged in during testing, and you’re trying to test the full login workflow again with the login dialog, you will need to delete cookies from Safari first. You can do this by going to the iOS settings app, selecting Safari and then Clear Cookies and Data. You will also need to delete the authToken from the keychain. There is a button on the YMSampleHomeViewController view that calls the deleteToken method so you can test this.\n\n\n**Make A Yammer REST API Call**\n\nThe “attemptYammerApiCall” method in YMSampleHomeViewController.m shows what you would typically do in your app to access the Yammer API. FIrst the code determines if the auth token is already available in the keychain. If it is, it makes the API call using the auth token. If not, it initiates the login process to obtain the token.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (IBAction)attemptYammerApiCall:(id)sender\\n{\\n    // Get the authToken if it exists\\n    NSString *authToken = [[YMLoginClient sharedInstance] storedAuthToken];\\n\\n    // If the authToken exists, then attempt the sample API call.\\n    if (authToken) {\\n\\n        NSLog(@\\\"authToken: %@\\\", authToken);\\n        [self makeSampleAPICall:authToken];\\n\\n    } else {\\n\\n        // This is an example of how you might\\n        self.attemptingSampleAPICall = YES;\\n\\n        // If no auth token is found, go to step one of the login flow.\\n        // The setPostLoginProcessDelegate is one possible way do something after login.  In this case, we set that delegate\\n        // to self so that when the login controller is done logging in successfully, the processAfterLogin method\\n        // is called in this class.  Usually in an application that post-login process will just be an\\n        // app home page or something similar, so this dynamic delegate is not really necessary, but provides some\\n        // added flexibility in routing the app to a delegate after login.\\n        [[YMLoginClient sharedInstance] startLogin];\\n    }\\n}\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"ios-sdk","type":"basic","title":"iOS SDK"}
The iOS SDK enables you to perform Yammer authentication to obtain an OAuth 2 token and then read/write to the Yammer REST API using this token. The SDK and a sample app using the SDK are available at: https://github.com/yammer/ios-yammer-sdk. **Setup** Register Custom Redirect URI The first step is to register a new Yammer app that represents your iOS app. During registration, set the Redirect URI to a custom URI Scheme i.e. AppName://your.custom.uri. Make sure the Scheme name (in this case AppName) is unique to your company and iOS app. Here’s an example for an iOS app named Move to Locker : [block:image] { "images": [ { "image": [ "https://files.readme.io/jbVPMV0Q0uKL0JguEV10_LoginWithYammer.png", "LoginWithYammer.png", "372", "89", "#343434", "" ] } ] } [/block] Specify URL Scheme During the login process, users will be directed to the mobile Safari web browser to complete the OAuth handshake. In order for the browser to be able to switch back to your iOS app after the handshake is done, the custom URL Scheme from above should be registered in the iOS application. Here’s how you do that: In the XCode Project Navigator of your iOS app, expand the Supporting Files group and open your app’s plist file. Add a new row by going to the menu and clicking Editor > Add Item. Select URL Types. Expand the URL Types key, expand Item 0, and add a new item: URL Schemes. For the Move to Locker app, this looks like: [block:image] { "images": [ { "image": [ "https://files.readme.io/QUeQuyWES8G9p2ITRfxK_URLScheme.png", "URLScheme.png", "456", "96", "#997f62", "" ] } ] } [/block] Integrate the SDK into your Project The SDK has been packaged as a Cocoapod. You can include the SDK in your project by installing Cocoapods, creating a Podfile and specifying that you want to include the YammerSDK pod. The first step is to install Cocoapods from the terminal by typing: sudo gem install cocoapods Then create a file called Podfile in your project's directory, open it with a text editor and add the following lines: [block:code] { "codes": [ { "code": "platform :ios, '7.0'\n\ntarget 'YOURTARGET' do\n\npod 'YammerSDK'\n\nend", "language": "text" } ] } [/block] Next type pod install from the command line in your project's folder. From now on you should open your project from the .xcworkspace file that Cocoapods has created. Configure Yammer OAuth service Update the following lines in the sample application's YMAppDelegate.m file with your client ID, secret and redirect URI from Yammer client application [block:code] { "codes": [ { "code": "- (void)configureLoginClient\n{\n /* Add your client ID here */\n [[YMLoginClient sharedInstance] setAppClientID:@\"APP CLIENT ID\"];\n\n /* Add your client secret here */\n [[YMLoginClient sharedInstance] setAppClientSecret:@\"APP CLIENT SECRET\"];\n\n /* Add your authorization redirect URI here */\n [[YMLoginClient sharedInstance] setAuthRedirectURI:@\"AUTH REDIRECT URI\"];\n}", "language": "text" } ] } [/block] If you plan to use the SDK in your own app make sure you add these lines into your application's app delegate in the application:didFinishLaunchingWithOptions: method. **Initiate User Login** Typically, a “Login with Yammer” button on your app’s login view will initiate OAuth 2 based user authentication. [block:image] { "images": [ { "image": [ "https://files.readme.io/v4QaerdKSsuUFe0J6zYx_LoginWithYammer.png", "LoginWithYammer.png", "372", "89", "#343434", "" ] } ] } [/block] Look at the “login” method in YMSampleHomeViewController.m to see how to initiate the OAuth login. [block:code] { "codes": [ { "code": "- (IBAction)login:(id)sender\n{\n [[YMLoginClient sharedInstance] startLogin];\n}", "language": "text" } ] } [/block] The “startLogin” method in YMLoginClient.m launches the iOS Safari web browser to bring up the OAuth login page where the user enters their Yammer credentials. After they enter their credentials, they are presented with an app authorization page for your iOS app with an “Allow” button. [block:code] { "codes": [ { "code": "- (void)startLogin\n{\n NSAssert(self.appClientID, @\"App client ID cannot be nil\");\n NSAssert(self.appClientSecret, @\"App client secret cannot be nil\");\n NSAssert(self.authRedirectURI, @\"Redirect URI cannot be nil\");\n \n NSString *stateParam = [self uniqueIdentifier];\n [[PDKeychainBindings sharedKeychainBindings] setObject:stateParam forKey:YMKeychainStateKey];\n \n NSDictionary *params = @{@\"client_id\": self.appClientID,\n @\"redirect_uri\": self.authRedirectURI,\n @\"state\": stateParam};\n\n NSString *baseUrlString = [NSString stringWithFormat:@\"%@/dialog/oauth\", YMBaseURL];\n NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:baseUrlString]];\n\n AFHTTPRequestSerializer * requestSerializer = [[AFHTTPRequestSerializer alloc] init];\n NSError *error;\n NSURLRequest *serializedRequest = [requestSerializer requestBySerializingRequest:request withParameters:params error:&error];\n\n if (error) {\n NSLog(@\"Failed to serialize request: %@\", error);\n }\n\n // Yammer SDK: This will launch mobile (iOS) Safari and begin the two-step login process.\n // The app delegate will intercept the callback from the login page. See app delegate for method call.\n [[UIApplication sharedApplication] openURL:serializedRequest.URL];\n}", "language": "text" } ] } [/block] **Handle Redirect URI** Once the user authorizes your iOS app by clicking on the “Allow” button, the browser redirects to the custom URL that you specified above. In order for the user to re-enter your app functionality, your app delegate should handle this redirect. For details on handling the redirect, open the sample app’s YMAppDelegate.m file and look at the following method: [block:code] { "codes": [ { "code": "- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {\n\n // If we arrive here it means the login was successful, so now let's get the authToken to be used on all subsequent requests\n-[YMLoginCClient handleLoginRedirectFromUrl:sourceApplication:]\n if ([[YMLoginClient sharedInstance] handleLoginRedirectFromUrl:url sourceApplication:sourceApplication])\n return YES;\n\n // URL was not a match, or came from an application other than Safari\n return NO;\n}", "language": "text" } ] } [/block] Note: Once the server sees that a user has clicked the Allow button, future login requests do not display the page with the Allow button. This is a one time occurance for each unique user/iOS app combination. Subsequent login attempts will return directly to the iOS app without the Allow page. You can manually Revoke Access to your app by going to https://www.yammer.com/account/applications. **Obtain User Auth Token** The “handleLoginRedirectFromUrl” method in YMLoginClient.m, called on handling the redirect, runs a few checks and then calls a method to obtain a user auth token from Yammer. The auth token is stored in the keychain. All subsequent calls to the Yammer API use this authToken as the key into the system. Here’s the method in YMLoginClient.m for obtaining the auth token. [block:code] { "codes": [ { "code": "- (void)obtainAuthTokenForCode:(NSString *)code\n{\n // Query params\n NSDictionary *params = @{\n @\"client_id\" : self.appClientID,\n @\"client_secret\" : self.appClientSecret,\n @\"code\" : code\n };\n\n // Yammer SDK: Note that once we have the authToken, we use a different constructor to create the client:\n // - (id)initWithAuthToken:(NSString *)authToken.\n // But we don't have the authToken yet, so we use this:\n YMAPIClient *client = [[YMAPIClient alloc] init];\n\n __weak typeof(self) weakSelf = self;\n\n [client postPath:@\"/oauth2/access_token.json\"\n parameters:params\n success:^(id responseObject) {\n \n NSDictionary *jsonDict = (NSDictionary *) responseObject;\n NSDictionary *access_token = jsonDict[@\"access_token\"];\n NSString *authToken = access_token[@\"token\"];\n \n // For debugging purposes only\n NSLog(@\"Yammer Login JSON: %@\", responseObject);\n NSLog(@\"authToken: %@\", authToken);\n \n // Save the authToken in the KeyChain\n [weakSelf storeAuthTokenInKeychain:authToken];\n \n [weakSelf.delegate loginClient:weakSelf didCompleteWithAuthToken:authToken];\n [[NSNotificationCenter defaultCenter] postNotificationName:YMYammerSDKLoginDidCompleteNotification object:weakSelf userInfo:@{YMYammerSDKAuthTokenUserInfoKey: authToken}];\n }\n failure:^(NSInteger statusCode, NSError *error) {\n NSMutableDictionary *userInfo = [@{NSLocalizedDescriptionKey: @\"Unable to retrieve authentication token from code\"} mutableCopy];\n if (error) {\n userInfo[NSUnderlyingErrorKey] = error;\n userInfo[NSLocalizedFailureReasonErrorKey] = [error localizedDescription];\n }\n \n NSError *newError = [NSError errorWithDomain:YMYammerSDKErrorDomain code:YMYammerSDKLoginObtainAuthTokenError userInfo:userInfo];\n \n [weakSelf.delegate loginClient:weakSelf didFailWithError:newError];\n [[NSNotificationCenter defaultCenter] postNotificationName:YMYammerSDKLoginDidFailNotification object:weakSelf userInfo:@{YMYammerSDKErrorUserInfoKey: newError}];\n }\n ];\n}", "language": "text" } ] } [/block] Note: The Safari browser in iOS will hold on to the auth token in a cookie in the browser. So if you have already logged in during testing, and you’re trying to test the full login workflow again with the login dialog, you will need to delete cookies from Safari first. You can do this by going to the iOS settings app, selecting Safari and then Clear Cookies and Data. You will also need to delete the authToken from the keychain. There is a button on the YMSampleHomeViewController view that calls the deleteToken method so you can test this. **Make A Yammer REST API Call** The “attemptYammerApiCall” method in YMSampleHomeViewController.m shows what you would typically do in your app to access the Yammer API. FIrst the code determines if the auth token is already available in the keychain. If it is, it makes the API call using the auth token. If not, it initiates the login process to obtain the token. [block:code] { "codes": [ { "code": "- (IBAction)attemptYammerApiCall:(id)sender\n{\n // Get the authToken if it exists\n NSString *authToken = [[YMLoginClient sharedInstance] storedAuthToken];\n\n // If the authToken exists, then attempt the sample API call.\n if (authToken) {\n\n NSLog(@\"authToken: %@\", authToken);\n [self makeSampleAPICall:authToken];\n\n } else {\n\n // This is an example of how you might\n self.attemptingSampleAPICall = YES;\n\n // If no auth token is found, go to step one of the login flow.\n // The setPostLoginProcessDelegate is one possible way do something after login. In this case, we set that delegate\n // to self so that when the login controller is done logging in successfully, the processAfterLogin method\n // is called in this class. Usually in an application that post-login process will just be an\n // app home page or something similar, so this dynamic delegate is not really necessary, but provides some\n // added flexibility in routing the app to a delegate after login.\n [[YMLoginClient sharedInstance] startLogin];\n }\n}", "language": "text" } ] } [/block]