title: How and when is the token refreshed when using BMS Client, and is there a way to force the refresh?
body: <p>We are using:</p>
  
  <pre><code>BMSClient.getInstance().registerAuthenticationListener("realm", new CustomAuthentication(this));
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>AuthorizationManager.createInstance(this.getApplicationContext());
  AuthorizationManager.getInstance().setAuthorizationPersistencePolicy(AuthorizationManager.PersistencePolicy.ALWAYS);
  </code></pre>
  
  <p>to store the authorization data on the phone. "The authorization data will be saved on local storage" is set to ALWAYS. </p>
  
  <p>The code above is always run on our splashscreen on startup so it is always run when the app restarted.</p>
  
  <p>The problem we have had is that after some time (hours or days) when what we suspect the token has expired we get response in the form of <strong>HTTP 307</strong>. Even after restarting the app we keep getting this response on our requests. The only way to get around it is to go into the app from settings and clear all data.</p>
  
  <p>The following questions would help us go forward in our testing and possible solution:</p>
  
  <ol>
  <li>How long is the token cached in BMSClient? (testing purposes)</li>
  <li>Can AuthorizationManager help us in any way to force a new fetch of token?</li>
  <li>Are they working on log out functionality?</li>
  </ol>
  
  <p>Our custom listener:</p>
  
  <pre><code>public class CustomAuth implements AuthenticationListener {
  
      private Context activityContext;
  
      public CustomAuth(Context activityContext) {
          this.activityContext = activityContext;
      }
  
      @Override
      public void onAuthenticationChallengeReceived(AuthenticationContext authContext, JSONObject challenge, Context context) {
          //1. read the challenge JSONObject
          //2. handle the challenge (use the context for handling UI based operations)
          //3. return response using the AuthenticationContext authContext
          SharedPreferences preferences = activityContext.getSharedPreferences("UserPreference", Context.MODE_PRIVATE);
          String email = preferences.getString("email", "");
          if(email.equals("")) {
              email = "unidentified-user@error.com";
          }
          JSONObject jsonEmail = new JSONObject();
          try {
              jsonEmail.put("email", email);
          } catch (JSONException e) {
              authContext.submitAuthenticationChallengeAnswer(null);
          }
          authContext.submitAuthenticationChallengeAnswer(jsonEmail);
  
      }
  
      @Override
      public void onAuthenticationSuccess(Context context, JSONObject info) {
          //additional operations in case of authentication success
          Log.d("Authentication", "Auth success: " + String.valueOf(info));
      }
  
      @Override
      public void onAuthenticationFailure(Context context, JSONObject info) {
          //additional operations in case of authentication failure
          Log.d("Authentication", "Auth failure ." + String.valueOf(info));
      }
  }
  </code></pre>