Getting error while trying to refresh boxSession (once the access token has expired)
- Dominant language
- Java
- Stars
- 64
- Forks
- 66
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
In my app, when I'm trying to refresh the boxEnterprise access token once the box token has expired, i get below error and once the token is refreshed (it takes sometime to refresh the token), everything works fine.
Below is the error logs:
`Unable to repair user
java.util.concurrent.ExecutionException: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at java.util.concurrent.FutureTask.report(FutureTask.java:94)
at java.util.concurrent.FutureTask.get(FutureTask.java:164)
at com.box.androidsdk.content.models.BoxSession$BoxSessionRefreshRequest.onSend(BoxSession.java:708)
at com.box.androidsdk.content.models.BoxSession$BoxSessionRefreshRequest.onSend(BoxSession.java:691)
at com.box.androidsdk.content.requests.BoxRequest.send(BoxRequest.java:190)
at com.box.androidsdk.content.BoxFutureTask$1.call(BoxFutureTask.java:38)
at com.box.androidsdk.content.BoxFutureTask$1.call(BoxFutureTask.java:31)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at com.box.androidsdk.content.models.BoxSession$2.run(BoxSession.java:496)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at com.box.androidsdk.content.auth.BoxAuthentication$4.call(BoxAuthentication.java:504)
at com.box.androidsdk.content.auth.BoxAuthentication$4.call(BoxAuthentication.java:446)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
02-08 16:28:58.239 27721-28460/com.allstate.view E/BoxSession: Unable to repair user
com.box.androidsdk.content.BoxException: An error occurred while sending the request
at com.box.androidsdk.content.requests.BoxRequest.onSend(BoxRequest.java:243)
at com.box.androidsdk.content.requests.BoxRequest.send(BoxRequest.java:190)
at com.box.androidsdk.content.models.BoxSession$BoxSessionAuthCreationRequest.onSend(BoxSession.java:764)
at com.box.androidsdk.content.models.BoxSession$BoxSessionAuthCreationRequest.onSend(BoxSession.java:744)
at com.box.androidsdk.content.requests.BoxRequest.send(BoxRequest.java:190)
at com.box.androidsdk.content.BoxFutureTask$1.call(BoxFutureTask.java:38)
at com.box.androidsdk.content.BoxFutureTask$1.call(BoxFutureTask.java:31)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)`
Could you please let me know if I'm doing something wrong.
Here is the code i tried for refresh the token:
`if (boxSession == null) {
boxSession = getBoxSession(context);
return boxSession;
} else if (currentTime > expiryTime) {
boxSession.refresh();
return boxSession;
} else {
return boxSession;
}`
I also tried to wrap the "boxSession.refresh()" call inside a thread and use it but still getting the same error.
Also, i have a custom refresh provider, which is being triggered automatically when i call "boxSession.refresh()", inside the refresh provider, i have logic to hit API to get my latest token from the API and override local one and also, update expiry time inside that.
Thanks!!
Contributor guide
Assessment
This issue has not been assessed yet.