Giter Site home page Giter Site logo

bahnbonus's People

Contributors

robbi5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bahnbonus's Issues

Authentification via OpenID

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.