box-ios-sdk icon indicating copy to clipboard operation
box-ios-sdk copied to clipboard

BOXContentClient.accessTokenDelegate Can not be setted in 2.0.2

Open wangqiwei66 opened this issue 6 years ago • 12 comments

We use appUser to present a box file content, and manage accesstoken for our own. In elder verison, I use BOXContentClient.default().authenticate() and wait the callback func: func fetchAccessToken(completion: ((String?, Date?, Error?) -> Void)!) In this func, I will return the accessToken and expiredDate to pass the authentication. But in v2.0.2 , the authenticate() didn't call this fetchAccessToken anymore. Search in source code, I found that the accessTokenDelegate didn't has a setter. Only a getter in BOXContentClient.m : image

When debuging my code, I found that even if I set the delegate , this var still nil . image Is that a error for the BOX? Or how could I use appuser to present a box file?

wangqiwei66 avatar Jan 09 '19 09:01 wangqiwei66

I can confirm, it's not calling fetchAccessToken any more. @wangqiwei66 I went back to 2.0.0 as that version is working fine.

rpelorosso avatar Jan 10 '19 02:01 rpelorosso

I can confirm, it's not calling fetchAccessToken any more. @wangqiwei66 I went back to 2.0.0 as that version is working fine.

Exactly. Now I can only rollback to 2.0.0. Pending on BOX team to fix the issue: add a setter for BOXContenClient.accessTokenDelegate var .

wangqiwei66 avatar Jan 10 '19 03:01 wangqiwei66

@cburnette Do you have context on this?

jlawton avatar Jan 10 '19 19:01 jlawton

@cburnette Any update for this issue?

wangqiwei66 avatar Jan 14 '19 03:01 wangqiwei66

@wangqiwei66 I just want to preview box files in swift ,I have accessToken and boxFileID. please let me know how to launch the box page in BoxpreviewSDK

Thanks,

knollyReddy avatar Jan 22 '19 10:01 knollyReddy

You might want to try instantiating a BOXContentClient with:

  • (BOXContentClient *)clientForServerAuthUser:(nonnull ServerAuthUser *)serverAuthUser initialToken:(nullable NSString *)token fetchTokenBlockInfo:(nullable NSDictionary *)fetchTokenBlockInfo fetchTokenBlock:(nonnull ServerAuthFetchTokenBlock)fetchTokenBlock;

and have your logic in fetchTokenBlock.

Looks like with the recent change, we don't need accessTokenDelegate anymore @cburnette?

thuyBox avatar Jan 22 '19 23:01 thuyBox

You might be interested in https://github.com/box/box-ios-sdk/blob/master/doc/BoxPlatform.md

thuyBox avatar Jan 22 '19 23:01 thuyBox

You might be interested in https://github.com/box/box-ios-sdk/blob/master/doc/BoxPlatform.md

1, If fetchAccessToken callback is deprecated, why I can see the code remains in BoxClient.h? DO you even think about the version compliance? image

2, How could I initial a serverAuthUser? We don't have a unique id or login string. image

wangqiwei66 avatar Jan 23 '19 07:01 wangqiwei66

@wangqiwei66 I've just updated https://github.com/box/box-ios-sdk/blob/master/doc/BoxPlatform.md — it should now contain working sample code in both Swift and Objective-C for instantiating a client using Server-to-Server auth. The unique ID you use can be any value, as long as it uniquely identifies the user you're authorizing. If you're just doing testing or don't have multiple users, you can use a dummy value like "DUMMY_USER_IDENTIFIER".

Unfortunately, the change made previously to improve support for App Users did contain some changes that were not backwards compatible. I'll try to clean some of those up in the next week or so, but you should regard the instructions in https://github.com/box/box-ios-sdk/blob/master/doc/BoxPlatform.md as authoritative. The way described there is the way that App Users will work in this SDK for the foreseeable future; the previous way using accessTokenDelegate is no longer supported.

mattwiller avatar Jan 30 '19 18:01 mattwiller

@mattwiller copy your swift code of let fetchToken. CAN NOT even pass the compile: image

wangqiwei66 avatar Feb 11 '19 02:02 wangqiwei66

@mattwiller you need add a ? for the completion: image

wangqiwei66 avatar Feb 11 '19 03:02 wangqiwei66

@wangqiwei66 We're in the process of cleaning up this interface and making those parameters non-optional, since they will always be passed to the ServerAuthFetchTokenBlock. Because of this, the documentation is slightly ahead of the latest released SDK version. You're right, you should be able to get around it for now by making these parameters optional. In the next SDK version, the parameters will no longer be optional.

mattwiller avatar Feb 12 '19 01:02 mattwiller

This issue has been automatically marked as stale because it has not been updated in the last 30 days. It will be closed if no further activity occurs within the next 7 days. Feel free to reach out or mention Box SDK team member for further help and resources if they are needed.

stale[bot] avatar Dec 19 '22 19:12 stale[bot]

This issue has been automatically closed due to maximum period of being stale. Thank you for your contribution to Box iOS SDK and feel free to open another PR/issue at any time.

stale[bot] avatar Dec 28 '22 08:12 stale[bot]