Question
Questions for BOX App User coding
A. This is the method used to authenticate the ‘old’ app which was using standard users and synchronizing to the individual logged in user’s Box account:
[BOXContentClient setClientID:@“xyz" clientSecret:@“abc"];
[[BOXContentClient defaultClient] authenticateInAppWithCompletionBlock:^(BOXUser *user, NSError *error) {
if (error == nil) {
NSLog(@"Logged in user: %@", user.login);
} else {
NSLog(@"Error occurred authenticating with Box: %@", error.description);
}
}];
If I merely replace the first line with the line below, which contains the clientID and clientSecret for the new app, it will not authenticate.
[BOXContentClient setClientID:@“elm" clientSecret:@"jul"];
Since we are wanting to use AppUsers instead of standard users, the documentation leads me to believe that we cannot use this method of authenticating with the new app. Is that the case?
B. The documentation leads you through the various things to do for oAuth2 but there is no clear, concise code sample showing how to create an oAuth2 session and authenticate. Can you provide?
C. If not, here is the code from some of the various attempts I have tried. I have imported the JWT pod into the application and tried to use it to create a JWT but when the encodePayload is called, it tries to connect and the Box error screen appears. It isn’t clear from the documentation what I would even do with the JWT if it were created successfully. Do I need to create a BoxParallelOAuth2Session or can I call the [BoxContentClient defaultClient] authenticateInAppWithCompletionBlock method? Again, a simple set of example code would be nice…using our clientID, clientSecret, AppID, etc would be even better.
Code that doesn’t work:
@try{
NSString *jti = [Guid newGuidString];
NSDate *exp = [NSDate date];
NSDictionary *payload = @{@"iss": @“abcdef", @"sub": @“***@example.com", @"box_sub_type": @"user", @"aud": @"https://api.box.com/oauth2/token", @"jti": jti, @"exp": exp};
NSString *secret = @“opqrst";
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
