We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
donaldp
5 years agoCollaborator | Level 9
expired token when set to not expire
Have read a few posts on related topics here, and something definitely not working correctly...
My app was doing weird things today, and I saw a expired token exception getting thrown. This has...
donaldp
5 years agoCollaborator | Level 9
Hi Greg,
Thanks for the extra info, but as per earlier post I'm still unable to get an exception using any of those methods. In the earlier case, I had been testing it within a C#/.NET property change. I thought perhaps it might be a limitation with properties, so I wrote the code as a separate method which I then call at the appropriate place. Still not getting an exception. So I thought, well if I'm not getting an exception, then let's assign it to something and see what's in it - I got nothing. Not a result, not a null, nothing. No further code from the method executes after the first call to the Dropbox server (i.e. none of the writelines), so it seems I'm simply not getting any response at all from the server (until I try other calls later in my app and start getting the exception). This is consistent with my first observations of incorrect behaviour in that my app displays the username or "not logged in" as the case may be, but neither was appearing on screen (so again, looks like the call was hung). Not sure what the time-out period is on such a call? At this point I'm not sure what else I can do to check the token is valid, as nothing I've tried so far works. See below (in the meantime I shall read-up about what I need to do to implement refresh tokens)...
CODE
async Task<bool> TokenIsValid()
{
System.Diagnostics.Debug.WriteLine($"********************************** {nameof(TokenIsValid)} is checking token {DxToken}");
DxClient??=new DropboxClient(DxToken);
try {
Account result=await DxClient.Users.GetCurrentAccountAsync();
if (result!=null) {
System.Diagnostics.Debug.WriteLine($"********************************** Name in result is {result.Name}");
} else {
System.Diagnostics.Debug.WriteLine($"********************************** Result is null!!");
}
}
catch (Exception ex) {
System.Diagnostics.Debug.WriteLine($"********************************** Exception in {nameof(TokenIsValid)}: {ex.Message}");
return false;
}
System.Diagnostics.Debug.WriteLine($"********************************** Token is valid!");
return true;
}
OUTPUT (note that I have no further output from TokenIsValid after that first writeline)
********************************** DropboxService is being initialised
********************************** TokenIsValid is checking token sl.....
********************************** OnAuthorisedChanged is running with value Authorised:True
********************************** DropboxService has been initialised
Exception thrown: 'Dropbox.Api.AuthException' in Dropbox.Api.dll
********************************** UNHANDLED EXCEPTION! Details: Dropbox.Api.AuthException: expired_access_token/..
at Dropbox.Api.DropboxRequestHandler.RequestJsonString(String host, String routeName, String auth, RouteStyle routeStyle, String requestArg, Stream body); Request Id: b156453a19334fd0bfd773534492fe9c
Exception thrown: 'Dropbox.Api.AuthException' in System.Private.CoreLib.dll
********************************** UNHANDLED EXCEPTION! Details: Dropbox.Api.AuthException: expired_access_token/..
at Dropbox.Api.DropboxRequestHandler.RequestJsonString(String host, String routeName, String auth, RouteStyle routeStyle, String requestArg, Stream body)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(); Request Id: b156453a19334fd0bfd773534492fe9c
thanks,
Donald.
donaldp
5 years agoCollaborator | Level 9
So tonight my screens went black all of a sudden, but computer didn't crash, so I did a hot-restart - Visual Studio was open at the time. When I re-opened everything and tried my app again to see if I'd lost anything (don't remember where I last saved) I was getting a response to my token-check! This brings up a few points...
1. maybe something glitchy on my machine?
2. maybe something glitchy on the server which is now resolved?
3. it did indeed take a while - heaps of other messages before the response - but I hadn't put any time-stamps in, so I'm not sure exactly how long it took, but it was a while.
4. the qualifier here is that it was no longer the same token, as I'd given up on that issue for today and signed out and back in so I could do some other work. Perhaps related to the token itself? I'll have to look into it some more when this token expires.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!