Complete
over 4 years ago

WERETECH-8848

Cannot Reproduce

makeWebRequest: bad request on some devices

Some devices got a bad request on next makeWebRequest: 

Communications.makeWebRequest("https://www.googleapis.com/calendar/v3/calendars/[email protected]/events",
{timeMin=>2020-4-30T12:19:00+02:00, timeMax=>2020-5-1T12:19:00+02:00},
{:method=>Communications.HTTP_REQUEST_METHOD_GET, :headers=>{ "Authorization"=>"Bearer "+"ya29…valid-oauth-token…
OpxLk" }}, method(:onEvents));

  1. in simulator it works fine
  2. in majority of devices it works fine
  3. the oauth token is valid: the login was confirmed and another request was successful
  4. Error 400: Bad Request on some devices: e.g.  iPhone X, iOS 13.4.1, Garmin Connect: 4.30
    1. same parameters work on https://developers.google.com/calendar/v3/reference/events/list
    2. the user even tested it works for his account in the simulator, but not in the device through his phone

Testing: 

  • by previous testing I realised in another request the device translated "showDeleted"=>false  to "showDeleted"=>0 and that was not accepted by Google on some devices while worked fine on most of them. So I fixed that one. 
  • but in the request above all the parameters are strings, so I don't see anything that can go wrong. 
  • from debugging couple of devices, I am almost sure the problem is caused inside the makeWebRequest. But I don't know what can go wrong. The debug data just looks good yet it replies with the Bad Request. 

What can be wrong there? 

The only idea I have is that it is something phone/app specific inside the makeWebRequest itself. 

Source, app.

  • Here is the log from the user that got the bad request: login & getting calendar is OK, but  3. reading calendar always fails on his device while works for him in the simulator and https://developers.google.com/calendar/v3/reference/events/list. We tried also to url encode the mail but no change. 

  • I don't have more info about the affected devices unfortunately. It seems to be more specific to the OS than the device. Most reports were from iPhones. The only one was from Android but that user did not reply with more data so that could be a different bug as well. 

    Devices and fw from which the bug was reported: 

    Devices: Vivoactive 3, FR
    945, Fenix 5 plus, FR645 Music

    Firmware: 330, 800, 9.10 (df7c02e), 1420, 3.90, 640

  • I don't have an access to a device where it does not work, but I'll bring a skilled user with the device where it does not work here and hopefully he can help. 

    So far 10 users reported it does not work for them but nobody provided enough data before. 

    On the devices where it does not work it never works. On the devices where it works it always works. 

    Thanks for investigating. I'd be happy if it could work for all. 

  • by previous testing I realised in another request the device translated "showDeleted"=>false  to "showDeleted"=>0 and that was not accepted by Google

    We had this same issue back in 2017. It looks like maybe it has crept back in. This was previously filed as CA-9124 and was confirmed to be fixed with GCM 3.1.6. I'm not sure how the issue came back.

     I am almost sure the problem is caused inside the makeWebRequest. But I don't know what can go wrong.

    This type of problem is a little difficult to debug from a device. I think we should have enough information to reproduce.. you seem to indicate that this problem only occurs with some devices, but you don't mention which ones. It might be helpful if you could provide this information.

    That said, if you did want to try to debug this, you could setup a proxy (like fiddler) on computer on your local network, and then configure it to log traffic. When you make the request, you should see the outgoing request and the incoming response. That may give you enough information to tell what is going on.

  • Nope. The auth is done through OAuth for devices, and that works fine. The problem you linked is related to google preventing some user-agents doing the auth. Here the problem is once the user is already authenticated.