WatchAuthenticator icon indicating copy to clipboard operation
WatchAuthenticator copied to clipboard

Fetch Key from Server closes app

Open renegadeandy opened this issue 3 years ago • 4 comments

Hi,

When I run this on a Samsung S21 FE Ultra, it shuts when I press 'Fetch key from server'.

The app worked on my previous phone (Huawei Honor 9) - so I am using the same server details, login details etc.

Looking at logcat, it seems to close on line 183 on MainActivity.java because it is getting a 403 rather than a 200 (but I know my credentials are correct!

Can you help?

renegadeandy avatar Apr 24 '22 17:04 renegadeandy

Okay I figured out why it didnt work.

The documentation says use : https://api.skagen.linkplatforms.com/v2/users/me/devices/ as one of the endpoints, which actually results in a HTTP 404.

The URL is : https://api.skagen.linkplatforms.com/v2/users/me/devices (without the final /).

The 404 is not exposed to the user resulting in the app crashing and then not being able to figure out what went wrong. I have added a toast message on a fork and will submit a pull request to expose the user error more clearly :)

renegadeandy avatar May 09 '22 09:05 renegadeandy

Pull request with code change and doc updates here : https://github.com/dakhnod/WatchAuthenticator/pull/2 @dakhnod we need your input now!

renegadeandy avatar May 09 '22 09:05 renegadeandy

Thanks for your investment in this. Could you explain why it crashed on one device but not on another device?

dakhnod avatar May 09 '22 09:05 dakhnod

Absolutely - it turns out it was probably not to do with the device (although I thought it was).

It was infact that I think there was a change on the Skagen API endpoints, so the one your readme said before was :

https://api.skagen.linkplatforms.com/v2/users/me/devices/ -- which on my old phone used to work. I think in the mean time, the team at skagen must have changed their code a bit, so now that URL didn't work.

On trying on my new phone, I realised that the URL above resulted in a HTTP 404 (not found), so I started experimenting and found that the URL was now :

https://api.skagen.linkplatforms.com/v2/users/me/devices -- i.e removing the final '/' -- which when changing it worked again!

So it was not a problem with android devices - more a change on the server side of skagen, which resulted in an app crash - because it didn't nicely handle the 404. Now at least, the app will make a toast notification telling the user the official response code from the call (404 in my example of this problem) and it will suggest checking the URLs to make sure there are not any typos - instead of just crashing without any message!

Hoorah!

renegadeandy avatar May 09 '22 10:05 renegadeandy