userbradley / BeReal

How does BeReal work (Under the hood)
https://breadnet.co.uk/how-be-real-works/
MIT License
157 stars 6 forks source link

[BUG] How to access /search endpoint #68

Closed hahhahahdnnah closed 8 months ago

hahhahahdnnah commented 9 months ago

Confirmation that this is an issue

For issues related to the API, or reverse engineering please open a discussion

Describe issue

I tried lot of tests with this endpoint but can't figure out how to use it. I used it with the path (ex. /api/search/profile/xyz), query parameters (ex. ?query, ?user, ?profile...) but I'm always getting 400 (Bad Request) errors. Is there any example on how to use it?

Are you willing to submit a PR to resolve this?

If the specification is clear I could do.

max21910 commented 9 months ago

It seems like you're encountering difficulties with accessing the endpoint correctly. The endpoint you're trying to access requires authentication and specific headers to be set in the request.

Here's an example of how you can authenticate and set the required headers in your request:

http

--

GET /api/search/profile/xyz?query=example_query HTTP/1.1
Host: bereal.com
Content-Type: application/grpc
Te: trailers
Bereal-App-Language: en-US
Bereal-Device-Language: en
Bereal-Device-Id: 42B868DA-8CF4-4501-8375-B4CDCAC3B15F
Bereal-App-Version: 2.3.2
Bereal-OS-Version: 17.3.1
Bereal-Platform: iOS
Bereal-User-Id: cT1PBLx47lUEwGAsyOhUH2jhdP22 (this is my id change it with your own id)
Bereal-App-Version-Code: 15894
Bereal-Timezone: Europe/Paris
Accept-Encoding: br;q=1.0, gzip;q=0.9, deflate;q=0.8
User-Agent: BeReal/2.3.2 (AlexisBarreyat.BeReal; build:15894; iOS 17.3.1)
Accept-Language: en-US;q=1.0, fr-FR;q=0.9
Bereal-Signature: MToxNzA5MjM4MTU4Ol8JItzQbiyPzbdSm8N9qgC6zxZtyINDmTV+L74m5Dn9
Authorization: Bearer [your_access_token]
Please make sure to replace [your_access_token] 

I also use MITMProxy connected to my iPhone running the BeReal application to monitor and analyze every request made.

By employing this setup, we can closely inspect the requests and responses exchanged between the BeReal app and their servers.

hahhahahdnnah commented 9 months ago

I am authenticated. The problem is that the endpoint is always responsing with a 400 error code. Your example: /api/search/profile/xyz?query=example_query also returned a 400 error, changing example_query with a real name.

max21910 commented 9 months ago

maybe this can help : https://shomil.me/bereal/

hahhahahdnnah commented 9 months ago

No, I'm sorry that doesn't help. It doesn't show a way on how to use /search endpoint. I know some time ago the /search endpoint worked like this: /api/search/profile?query=xyz where all users with xyz were displayed. Badly thats not the case any more. The only thing this endpoint returns is a 400 error (Bad Request (the request exists but my query (/api/search/profile?query=xyz) was bad)). Can you provide an example when you use the search function in bereal?

max21910 commented 8 months ago

Hi, sorry for the delay. A 400 error can mean that BeReal changed this API request, so it's no longer available. If I find a similar API request like the search API you're trying to use, I will message you about it. Have a great day!