robbi5 / bahnbonus Goto Github PK
View Code? Open in Web Editor NEWAPI Documentation for BahnBonus, the loyality system of DB
API Documentation for BahnBonus, the loyality system of DB
I'm trying to write a small script (Python) to see when my BahnBonus points are going to expire. However, as a newby to web-programming I struggle to obtain the bearer token from the bahn-login.
Do you have any hint on how to proceed, or where to look at?
I did not really find a lot of helpful information on this process, however I also don't expect you to give basic tech support.
import openid
import requests
from bs4 import BeautifulSoup
from getpass import getpass
auth_url = 'https://auth.businesshub.deutschebahn.com/auth/realms/kubi/protocol/openid-connect/auth'
if __name__=='__main__':
session = requests.Session()
params = dict(scope= 'openid profile user:read user:write',
client_id= 'kubi',
redirect_uri= 'kubi://authentication/redirect',
response_type= 'code')
res1 = session.get(auth_url, params=params)
assert res.ok, 'could not get auth url'
login_soup = BeautifulSoup(res.content.decode(), 'html.parser')
login_form = login_soup.find(id='kc-form-login')
post_url = login_form.attrs['action'] # this is the POST url of the login form, e.g. https://accounts.bahn.de/auth/realms/db/login-actions/authenticate?session_code=XX&execution=XX&client_id=mob_esuite&tab_id=f'
username = input('Please enter username:\n').strip()
password = getpass('Please enter password:\n').strip()
res2 = session.post(post_url, data={'username':username,
'password':password})
# res1.content==res2.content, mostly same website gets returned?
probably it might be better to write this in JS after all?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.