notmarek / BeFake

BeReal Python API wrapper
131 stars 29 forks source link

403 Forbidden #79

Closed sanderDijkxhoorn closed 1 year ago

sanderDijkxhoorn commented 1 year ago

python3 -m BeFake feed friends Traceback (most recent call last): File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.9/dist-packages/BeFake/main.py", line 378, in cli(obj={}) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1130, in call return self.main(args, kwargs) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 760, in invoke return __callback(args, *kwargs) File "/usr/local/lib/python3.9/dist-packages/BeFake/main.py", line 29, in wrapper return func(bf, args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/BeFake/main.py", line 102, in feed feed = bf.get_friends_feed() File "/usr/local/lib/python3.9/dist-packages/BeFake/BeFake.py", line 238, in get_friends_feed res = self.api_request("get", "feeds/friends") File "/usr/local/lib/python3.9/dist-packages/BeFake/BeFake.py", line 98, in api_request res.raise_for_status() File "/usr/local/lib/python3.9/dist-packages/httpx/_models.py", line 736, in raise_for_status raise HTTPStatusError(message, request=request, response=self) httpx.HTTPStatusError: Client error '403 Forbidden' for url 'https://mobile.bereal.com/api/feeds/friends' For more information check: https://httpstatuses.com/403

or

python3 -m BeFake me Traceback (most recent call last): File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.9/dist-packages/BeFake/main.py", line 378, in cli(obj={}) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1130, in call return self.main(args, kwargs) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 760, in invoke return __callback(args, *kwargs) File "/usr/local/lib/python3.9/dist-packages/BeFake/main.py", line 29, in wrapper return func(bf, args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/BeFake/main.py", line 79, in me user = bf.get_user_info() File "/usr/local/lib/python3.9/dist-packages/BeFake/BeFake.py", line 228, in get_user_info res = self.api_request("get", "person/me") File "/usr/local/lib/python3.9/dist-packages/BeFake/BeFake.py", line 98, in api_request res.raise_for_status() File "/usr/local/lib/python3.9/dist-packages/httpx/_models.py", line 736, in raise_for_status raise HTTPStatusError(message, request=request, response=self) httpx.HTTPStatusError: Client error '403 Forbidden' for url 'https://mobile.bereal.com/api/person/me' For more information check: https://httpstatuses.com/403

i tied refreshing the token and logging in again but so far the same error…

ohld commented 1 year ago

The same for me. Probably, they implemented something new.

valerierx commented 1 year ago

On it right now, it appears that the 1.0 update caused some havoc. There will be breaking changes like additional photos soon

Edit: Okay, login process has gotten even more complicated. Token needs to be sent to Firebase to get another token that gets sent back to auth.bereal.team. Also choosing a device ID will be mandatory since we may need to actually register your BeFake token as an actual BeReal installation. Also @notmarek can you get me the client_id and client_secret you get at https://auth.bereal.team/token? I only have those for android that I'll publish right away, as they're the same for every build.

valerierx commented 1 year ago

There are now two tokens to manage and store: an access_token for use with mobile.bereal.com and an id_token for use with all firebase-related stuff.

sanderDijkxhoorn commented 1 year ago

Is there a temporarily way to manually put in my bearer token?

I got my bearer and refresh token just not sure what is saved in the token.txt

sanderDijkxhoorn commented 1 year ago

Wrote a little example code and this works just fine got a temporary solution for myself.


const fs = require('fs');

// User info
let url = "https://mobile.bereal.com/api/feeds/friends-v1";
let AuthroizationToken = "Bearer SussyBakaDon'tTryTOStealMyToken";
let deviceId = "COOL-DEVICE-ID";

// Headers
let headers = {
    "Accept-Encoding": "br;q=1.0, gzip;q=0.9, deflate;q=0.8",
    "Accept-Language": "en-NL;q=1.0, nl-NL;q=0.9",
    "Authorization": AuthroizationToken,
    "bereal-app-language": "en-NL",
    "bereal-app-version": "1.0.1-(9513)",
    "bereal-device-id": deviceId,
    "bereal-device-language": "en",
    "bereal-os-version": "15.4.1",
    "bereal-platform": "iOS",
    "bereal-timezone": "Europe/Amsterdam",
    "bereal-user-agent": "Bereal/1.0.1 (AlexisBarreyat.BeReal; build:9513; iOS 15.4.1) 1.0.0/BRApriKit",
};

// Make a request using native fetch nodejs to the url and save the response (body) which is json to a file called response.json
fetch(url, { headers: headers })
    .then((response) => response.json())
    // Save the response (body) to a file called response.json
    .then((json) => fs.writeFileSync('response.json', JSON.stringify(json)))
    .catch((error) => console.error(error));
valerierx commented 1 year ago

token.txt stores your refresh token, but it's gonna be deprecated. You can try my WIP branch at #80 that logs perfectly with vonage if you need a solution right now.

sanderDijkxhoorn commented 1 year ago

token.txt stores your refresh token, but it's gonna be deprecated. You can try my WIP branch at #80 that logs perfectly with vonage if you need a solution right now.

Thanks, I will check it out 👍

ohld commented 1 year ago

For ones who asks yourself how to make the old code work:

  1. Update library. Better to clone master brunch and use it locally. Run git pull to update it.
  2. You need to update tokens
from BeFake.BeFake.BeFake import BeFake
bf = BeFake()
bf.legacy_load()
bf.save()
  1. After that you can simply bf.load() as usual. Now you got the login token updated and saved in a new format.