save and use auth data in box android API

前端 未结 2 1766
无人及你
无人及你 2021-01-16 09:16

I am creating an box android app that allows user to upload media files on their account. I have set up my client id and client secret,it is authenticating my app too. Uploa

2条回答
  •  爱一瞬间的悲伤
    2021-01-16 09:33

    So for the auth refresh there are a couple of things to be considered:

    1. box client automatically refreshes OAuth tokens, you'll want to attach a OAuthRefreshListener to listen to the refresh, if you want to persist, persist the oauth data passed into the refresh listener. The listener only update your persisted oauth data, you don't need to re-authenticate in the refresh listener, sdk does the re-authenticate automatically.
    2. When you first initiate box client, you need to authenticate either by persisted auth, or the OAuth UI. The logic should be:

      check client.isAuthenticated();

      2.1 If authenticated, do nothing.

      2.2 if not authenticated, try to check whether there's persisted auth data. If so, authenticate by client.authenticate(oauthdata);

      2.3 if 2.2 failed, start OAuth UI flow.

      2.4 at last, in case of OAuthFatalFailureException, start OAuth UI flow.

提交回复
热议问题