pstoppani pstoppani - 1 month ago 9
iOS Question

How to logout a user using Box V2 iOS SDK

In the V1 iOS SDK it was possible to logout the current user as follows:

[Box logoutWithCallbacks:^(id <BoxOperationCallbacks> on)
{
on.after(^(BoxCallbackResponse response)
{
});
}];


How is it done using the V2 SDK?

Answer

Here's what I do:

BoxSDK *sdk = ... // a reference to the BoxSDK for the user
sdk.OAuth2Session.accessToken = @"INVALID_TOKEN";
sdk.OAuth2Session.refreshToken = @"INVALID_TOKEN";

That's it. The next time you try to do anything with the user's session you will be forced to log in again.

Update - you can see this in action in the Box sample app at https://github.com/box/box-ios-sdk-sample-app. Look at the BoxFolderViewController.m file.

Comments