简体   繁体   中英

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?

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.

This is how to logout correctly

[BoxSDK sharedSDK].OAuth2Session.accessToken = nil;
[BoxSDK sharedSDK].OAuth2Session.refreshToken = nil;

这是使用来自https://github.com/box/box-ios-sdk的最新 SDK 的方式

[BOXContentClient logOutAll];

swift version answer for logout box sdk session *

   boxClient.destroy { (res) in
                
   }
   boxClient = nil

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM