-1

i integrated ios box v2 sdk with my app. I can do all operations other than getting the logged in user info like name, email and so on. Any one solved this issue?. Please let me know.

There is a class called "BoxUser" but i do not know from where and how to call that class and get the info i want.

Thanks

loganathan
  • 2,056
  • 2
  • 23
  • 34

3 Answers3

4

There is a function provided for getting the current user info in the sdk :

[[BoxSDK sharedSDK].usersManager userInfoWithID:BoxAPIUserIDMe requestBuilder:nil     success:successBlock failure:failureBlock];
Ravi Jain
  • 86
  • 1
  • 4
1
NSString *str =  [NSString stringWithFormat:@"https://api.box.com/2.0/users/me?access_token=%@",str_access_token];


    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:str]
                                                  cachePolicy:NSURLCacheStorageAllowed
                                              timeoutInterval:20];

    [NSURLConnection sendAsynchronousRequest:request
                                       queue:[[NSOperationQueue alloc] init]
                           completionHandler:^(NSURLResponse *response,
                                               NSData *data,
                                               NSError *error) {

                               if ([data length] >0 && error == nil) {


                                   NSError *myError = nil;

                                   NSMutableDictionary *userdata = [[NSMutableDictionary alloc] initWithDictionary:[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&myError]];

                               } else if ([data length] == 0 && error == nil) {

                                   NSLog(@"Nothing was downloaded.");

                               } else if (error != nil) {

                                   NSLog(@"Error = %@", error);
                               }
                           }];
sunil
  • 300
  • 3
  • 20
  • BoxOAuth2Session *session = (BoxOAuth2Session *) [notification object]; NSLog(@"Access token (%@) expires at %@", session.accessToken, session.accessTokenExpiration); – sunil Aug 08 '14 at 13:54
0
METHOD
GET /users/me

EXAMPLE REQUEST
curl https://api.box.com/2.0/users/me
-H "Authorization: Bearer ACCESS_TOKEN"

More

Maulik
  • 19,348
  • 14
  • 82
  • 137
  • this is the api right. I hope that there is a simple way to get using box v2 ios sdk. And idea on that?. Also this requires another http request. – loganathan Dec 05 '13 at 07:41
  • I think you need to make a new request for user details. – Maulik Dec 05 '13 at 07:47