Declare the header file for EpamAuth:
1 |
#import "EpamAuth.h" |
Then declare a property that conforms to the Authorization interface.
1 2 3 4 5 6 |
@interface ViewController () { } @property (nonatomic, strong) id <Authorization> auth; @end |
Then initialize the property in init or a lazyloading accessor
1 |
self.auth = [EpamAuth defaultAutho]; |
Finally, use it like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[self.auth loginAndGetProfileDataForController:self withCompletion:^(NSError *error, NSDictionary * profile) { if(!error && profile) { NSLog(@"%@", [profile objectForKey:@"city"]); NSLog(@"%@", [profile objectForKey:@"country"]); NSLog(@"%@", [profile objectForKey:@"department"]); NSLog(@"%@", [profile objectForKey:@"jobTitle"]); NSLog(@"%@", [profile objectForKey:@"givenName"]); NSLog(@"%@", [profile objectForKey:@"mail"]); NSLog(@"%@", [profile objectForKey:@"telephoneNumber"]); NSLog(@"%@", [profile objectForKey:@"usageLocation"]); NSLog(@"%@", [profile objectForKey:@"userPrincipalName"]); } }]; |
If its your first time logging in, you will have a login window appear. Sign in using your EPAM credentials.
If you have previously logged in, your authentication token will be saved in the keychain, and you don’t have to log in a second time. You simply will be automatically logged in.
To log out:
1 2 3 4 |
//log out the current user [self.auth logoutWithCompletion:^(NSError *error) { NSLog(@"logged out"); }]; |