Skip to content

Commit

Permalink
setup preparation
Browse files Browse the repository at this point in the history
  • Loading branch information
hirschrobert committed Feb 9, 2021
1 parent 55cd73c commit f2d98d6
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 42 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
/database
/test
__pycache__/
/build
/dist
*.egg-info
!.gitignore
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/) ![CodeQL](https://github.com/hirschrobert/pybanking/workflows/CodeQL/badge.svg?branch=main)
## Alphaversion!!

## pybanking - a banking backend client at your service
## pybanking - a backend banking client at your service

### backend client for banking api (Deutsche Bank)

Expand Down
Empty file added config/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions config/db_api.ini.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[db_api]
client_id = put_your_client_id_here
client_secret = put_your_client_secret_here
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"
33 changes: 33 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[metadata]
name = pybanking-hirschrobert
version = 0.0.1
url = https://github.com/hirschrobert/pybanking
author = Robert Hirsch
author_email = [email protected]
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Operating System :: POSIX :: Linux
description = a backend banking client at your service
long_description = file: README.md
long_description_content_type = text/markdown

[options]
python_requires = >=3.8
install_requires =
beautifulsoup4>=4.8.2
dataset>=1.4.4
lxml>=4.5.0
oauthlib>=3.1.0
requests>=2.22.0
requests-oauthlib>=1.3.0
SQLAlchemy>=1.3.23
urllib3>=1.25.8
include_package_data = True
packages = find:

[options.packages.find]
exclude=test

[options.package_data]
config = *.ini.sample
Empty file added src/controller/__init__.py
Empty file.
Empty file added src/model/__init__.py
Empty file.
41 changes: 1 addition & 40 deletions src/pybank.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
from src.controller.authorize import Authorize

config = configparser.ConfigParser()
config.read('./.config/db_api.ini') # change if necessary
tokenfile = './.config/access_token.json'
config.read('./config/db_api.ini') # change if necessary

client_id = config['db_api']['client_id']
client_secret = config['db_api']['client_secret']
Expand All @@ -42,44 +41,6 @@
tokenurl = 'https://simulator-api.db.com/gw/oidc/token'
api = 'https://simulator-api.db.com/gw/dbapi/banking'

def init():
oauth = OAuth2Session(client_id, redirect_uri=redirect_uri, scope=scope)
authorization_url, state = oauth.authorization_url(authorize_endpoint)

print('Bitte diese Seite im Browser öffnen und den sechstelligen Wert von \"code\" aus der Adresszeile kopieren und hier einfügen:\n', authorization_url)

#authorization_response = input('Bitte code eingeben: ')

try:
authorization_response = initAuto(config)
except ValueError as err:
print(err)
return -1


payload = {
'grant_type': 'authorization_code',
'code': authorization_response,
'redirect_uri': redirect_uri
}
data_string = client_id + ":" + client_secret
data_bytes = data_string.encode("utf-8")
headers = {
'Authorization': "Basic " + base64.b64encode(data_bytes).decode("utf-8"),
'Content-Type': "application/x-www-form-urlencoded",
'cache-control': "no-cache"
}
now = int(time.time())
response = requests.post(tokenurl, data=payload, headers=headers)
print(response.text)

timeadd = { 'creation_time': now}
jsonresult = json.loads(response.text)
jsonresult.update(timeadd)
with open(tokenfile, 'w') as outfile:
json.dump(jsonresult, outfile,indent=2)
return jsonresult['access_token']

def tokenIsOutdated(creation_time,expires_in):
if ((creation_time + expires_in) < int(time.time())):
return True
Expand Down

0 comments on commit f2d98d6

Please sign in to comment.