MJ-Prod commited on
Commit
de923de
·
1 Parent(s): fd0dd6b

JWT-update

Browse files
Files changed (2) hide show
  1. app.py +11 -9
  2. docs/fiscal_knowledge.md +1 -1
app.py CHANGED
@@ -150,23 +150,25 @@ def plaid_exchange_token(
150
  try:
151
  access_token = exchange_public_token(request.public_token)
152
 
153
- # Save to Supabase
154
- requests.post(
155
- f"{SUPABASE_URL}/rest/v1/bank_connections",
156
- headers=SUPABASE_HEADERS,
 
 
 
157
  json={
158
- "user_id": user["sub"],
159
- "plaid_access_token": access_token,
160
- "institution_name": "Connected Bank",
161
- "connected_at": "now()"
162
  }
163
  )
 
 
164
  return {"status": "connected"}
165
  except Exception as e:
166
  print(f"Exchange token error: {e}")
167
  raise HTTPException(status_code=500, detail=str(e))
168
 
169
-
170
  @app.delete("/account")
171
  def delete_account(
172
  credentials: HTTPAuthorizationCredentials = Depends(security),
 
150
  try:
151
  access_token = exchange_public_token(request.public_token)
152
 
153
+ # Save via Supabase Edge Function (avoids HF DNS restrictions)
154
+ resp = requests.post(
155
+ f"{SUPABASE_URL}/functions/v1/save-bank-token",
156
+ headers={
157
+ "Authorization": f"Bearer {credentials.credentials}",
158
+ "Content-Type": "application/json"
159
+ },
160
  json={
161
+ "access_token": access_token,
162
+ "institution_name": "Connected Bank"
 
 
163
  }
164
  )
165
+ print(f"Save bank token: {resp.status_code} {resp.text}")
166
+
167
  return {"status": "connected"}
168
  except Exception as e:
169
  print(f"Exchange token error: {e}")
170
  raise HTTPException(status_code=500, detail=str(e))
171
 
 
172
  @app.delete("/account")
173
  def delete_account(
174
  credentials: HTTPAuthorizationCredentials = Depends(security),
docs/fiscal_knowledge.md CHANGED
@@ -1399,4 +1399,4 @@ Tips to start saving for retirement:
1399
  * talk to your financial institution about registered plans that may help you save for retirement
1400
 
1401
  ### Balancing your current financial priorities
1402
- Saving for retirement can be difficult when you have other demands on your money such as a mortgage, rent, car payments, or student loans. Make a budget to help you figure out how much money you can afford to save for retirement.
 
1399
  * talk to your financial institution about registered plans that may help you save for retirement
1400
 
1401
  ### Balancing your current financial priorities
1402
+ Saving for retirement can be difficult when you have other demands on your money such as a mortgage, rent, car payments, or student loans. Make a budget to help you figure out how much money you can afford to save for retirement.