ubahnverleih / WoBike

Documentation of Bike Sharing APIs 🚴🛴🛵
958 stars 131 forks source link

Invalid request for Bolt (Europe) #225

Open MiteEnBois opened 3 years ago

MiteEnBois commented 3 years ago

I am trying to use the sms verification, but the parameters on the confirmation is apparently invalid. I am using the parameters explained in the .md, but it just doesnt work This is the parameters that are supposed to work

{
  "phone_uuid" : "<UUID>",
  "verification" : {
    "confirmation_data" : {
      "code" : "1234"
    }
  },
  "phone" : "<phone number, non url-encoded>"
}

this are my parameters, just about the same

{
    "phone_uuid": "UUID",
    "phone": "phonenumber",
    "verification": {"confirmation_data": {"code": "1234"}},
}

and this is the response i get {"code":702,"message":"INVALID_REQUEST","validation_errors":[{"error":"Is not object","property":"verification","children":[]}]}

My guess is that it misses a parameters somewhere, but i dont know what.

pedrohsroque commented 3 years ago

I think you forgot the phone parameter in the body { "phone_uuid" : "29537f13-1234-1234-1234-40d6d297025e", "verification" : { "confirmation_data" : { "code" : "1234" } }, "phone" : "+5531999999999" }

MiteEnBois commented 3 years ago

Nope i had it, it was just in another order. I tried your parameters and ended up with the same error

{"code":702,"message":"INVALID_REQUEST","validation_errors":[{"error":"Is not object","property":"verification","children":[]}]}

pedrohsroque commented 3 years ago

@MiteEnBois those parameters are just an example, they are not expected to work,

You also need to do the previous step, try this 2 bodys, the sms code will be sent to this: https://receive-smss.com/sms/4915207955279/

POST https://user.bolt.eu/user/register/phone { "phone" : "+4915207955279", "preferred_verification_method" : "sms", "phone_uuid" : "cff09d97-4954-41b7-bd37-d8061ad3ff30", "appsflyer_id" : "1234567890123-1234567" }

POST https://user.bolt.eu/user/confirmVerification/ { "phone_uuid" : "cff09d97-4954-41b7-bd37-d8061ad3ff30", "verification" : { "confirmation_data" : { "code" : "9760" } }, "phone" : "+4915207955279" }

MiteEnBois commented 3 years ago

i was already doing this, and it worked, but inputing the code didn't change anything, and with your parameters it still doesn't work. I can show you my python code if you want, maybe its as simple as a typo somewhere

import requests

URL = "https://user.bolt.eu/user/register/phone"
PARAM = {
    "phone": "+447901614024",
    "preferred_verification_method": "sms",
    "phone_uuid": "cff09d97-4954-41b7-bd37-d8061ad3ff30",
    "appsflyer_id": "1234567890123-1234567"
}

r = requests.post(url=URL, data=PARAM)
print(r.text)

URL = "https://user.bolt.eu/user/confirmVerification/"
code = input("SMS Code : ")
PARAM = {
    "phone_uuid": "cff09d97-4954-41b7-bd37-d8061ad3ff30",
    "verification": {
        "confirmation_data": {
            "code": code
        }
    },
    "phone": "+4915207955279"
}
r = requests.post(url=URL, data=PARAM)
print(r.text)

URL = "https://rental-search.bolt.eu/categoriesOverview"
PARAM = {
    "lat": "50.0000",
    "lng": "10.0000",
    "version": "CI.23.0",
    "deviceId": "352229114789661",
    "deviceType": "iphone",
    "device_name": "iPhone12,3",
    "device_os_version": "iOS15.0",
    "language": "en"}
r = requests.get(url=URL, params=PARAM)
print(r.text)

The last code block is the requests to get all scooter data in the area, and it doesnt work because i cannot send the verification code, as seen below. and this is the console output:

{"code":0,"message":"OK","data":{"verification":{"method":"sms","confirmation_data":{}},"resend_confirmation_interval_ms":20000}}
SMS Code : 1872 
{"code":702,"message":"INVALID_REQUEST","validation_errors":[{"error":"Is not object","property":"verification","children":[]}]}
{"code":503,"message":"NOT_AUTHORIZED"}

Obviously i used the web phone thing you linked and used the real code sent by the api, but i still got the same error !

pedrohsroque commented 3 years ago

try this on the post request: r = requests.post(url=URL, json=PARAM) since the body is a json

MiteEnBois commented 3 years ago

aaaaaah, that was it, thank you!

MiteEnBois commented 3 years ago

Great, now i cannot get authorized. I tried doing the get request from [https://rental-search.bolt.eu/categoriesOverview]( ), with the same deviceid from the previous requests, even after the verification is validated and returns the needed data. I used the uuid that you included in your example, with my phone number, but i guess it doesn't work I have no idea how the deviceid and the other device parameters are used, i dont know what i am supposed to get, i have an android and they dont seem to have a "UUID" like iphones do. I am confused as to why my requests are denied even tho i use the same parameters. I guess its another python mishap, but i am really guessing

Here is the code for the last request

URL = "https://rental-search.bolt.eu/categoriesOverview"
PARAM = {
    "lat": "50.00000000",
    "lng": "10.00000000",
    "version": "CI.24.0",
    "deviceId": "cff09d97-4954-41b7-bd37-d8061ad3ff30",
    "deviceType": "iphone",
    "device_name": "iPhone12,3",
    "device_os_version": "iOS15.0",
    "language": "en"}

r = requests.get(url=URL, params=PARAM)
print(r.text)

The verification code is the same as before I used the same syntax as another working get request, but maybe i messed up somewhere I tried re-validating with other phone numbers, other uuid, but nothing worked, i just get a code 503 "NOT_AUTHORIZED"

pedrohsroque commented 3 years ago

@MiteEnBois now we are at the same point: https://github.com/ubahnverleih/WoBike/issues/211

LukeStonehm commented 2 years ago

Good day chaps.

The solve here is very simple. The requests to https://rental-search.bolt.eu/categoriesOverview require what Bolt calls "Basic" authorization.

Include the header Authorization with the value Basic <token>. The token value is also simple to generate: Base64 this combo -> <phone-number>:<deviceId> Example: +27124212211:cff09d97-4954-41b7-bd37-d8061ad3ff30 - when Base64'd = KzI3MTI0MjEyMjExOmNmZjA5ZDk3LTQ5NTQtNDFiNy1iZDM3LWQ4MDYxYWQzZmYzMA==

Example command I used from the terminal on Ubuntu: echo -n "+27124212211:cff09d97-4954-41b7-bd37-d8061ad3ff30" | base64.

I'll create a PR for Bolt EU so that this info can help others.

ossings commented 2 years ago

Can confirm that this worked for me, thank you @LukeStonehm

Embretr commented 2 years ago

I tried running the code excactly as described here (with my own info of course), but i get this response when trying to register my phone:

{"code":702,"message":"INVALID_REQUEST","validation_errors":[{"error":"Is required","property":"version"},{"error":"Is required","property":"deviceId"},{"error":"Is required","property":"deviceType"},{"error":"Is required","property":"device_name"},{"error":"Is required","property":"device_os_version"},{"error":"Is required","property":"language"}]}

has the API changed so this doesnt work anymore, or am I just doing something wrong?

BastelPichi commented 1 year ago

Please close this.