Skip to content

Commit 1ee60fc

Browse files
committed
Fix Grass collector: use /retrieveUser endpoint for totalPoints
1 parent d115de5 commit 1ee60fc

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

app/collectors/grass.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
"""Grass earnings collector.
22
3-
Uses the Grass API with an access token (from browser session) to fetch
4-
cumulative points. Grass uses OTP email login with no password, so users
5-
must provide their access token from the browser.
3+
Uses the Grass API with an access token (from browser localStorage) to
4+
fetch cumulative points from the /retrieveUser endpoint.
65
76
To get the token: open app.grass.io, log in, press F12, go to
87
Application > Local Storage, and copy the `accessToken` value.
@@ -42,25 +41,22 @@ async def collect(self) -> EarningsResult:
4241

4342
async with httpx.AsyncClient(timeout=30) as client:
4443
resp = await client.get(
45-
f"{API_BASE}/users/earnings/epochs",
44+
f"{API_BASE}/retrieveUser",
4645
headers=headers,
4746
)
4847

4948
if resp.status_code in (401, 403):
5049
return EarningsResult(
5150
platform=self.platform,
5251
balance=0.0,
53-
error="Token expired — get a new one from app.grass.io browser console: localStorage.getItem('token')",
52+
error="Token expired — get a new accessToken from app.grass.io Local Storage",
5453
)
5554

5655
resp.raise_for_status()
5756
data = resp.json()
5857

59-
# Extract total cumulative points from epochs
60-
epoch_earnings = data.get("result", {}).get("data", {}).get("epochEarnings", [])
61-
total_points = 0.0
62-
if epoch_earnings:
63-
total_points = float(epoch_earnings[0].get("totalCumulativePoints", 0))
58+
user = data.get("result", {}).get("data", {})
59+
total_points = float(user.get("totalPoints", 0))
6460

6561
return EarningsResult(
6662
platform=self.platform,

0 commit comments

Comments
 (0)