2

I am writing a framework that wraps functionalities of Box, for that I am using the box-ios-sdk. But all of their authentication methods uses their own flow. I have to input the appID and appSecret and then start the process to get an access token that is managed internally by the sdk.

The deal is that I already have my own OAuth2 Flow implemented, I already have the accessToken and the refresh token for the boxAPI. So how to use (or initialize somehow) the box-ios-sdk with the tokens that I already have?

Example:

[[BOXOAuth2Session alloc] initWithAccesstoken:(NSString *) refreshToken:(NSString *) expireDate:(NSDate *)];

or

[[BoxClient alloc] initWithAccesstoken:(NSString *) refreshToken:(NSString *) expireDate:(NSDate *)];

I`ve been digging into the documentation and the source code, but still have not found any viable way to do it.

1 Answers1

3

Assuming you have completely taken over the oAuth flow, including the refreshing of access tokens at the necessary times, you might be able to use the "App Users" mode of the SDK.

Here is the documentation for that: https://github.com/box/box-ios-sdk/blob/master/doc/AppUsers.md

In this mode, you basically just need to set an "BOXAPIAccessTokenDelegate" on the BOXContentClient that you're working with, and then implement the "fetchAccessTokenWithCompletion:" delegate method to provide your own access token. In this mode, you just need to ensure that your implementation of "fetchAccessTokenWithCompletion:" always returns a valid access token.

Rico Yao
  • 971
  • 7
  • 9