import requests from oauthlib.oauth2 import BackendApplicationClient from requests_oauthlib import OAuth2Session, OAuth2 import jsonapi_requests from orm.my_meta import MyMeta # constants: root_url = 'https://farmos.wagframe.duckdns.org/' api_root = root_url + 'api/' token_url = root_url + 'oauth/token/' client_id = 'neofarm' client_secret = 'Wk&%g#d8lYFUDrU7k7k%5ZS$V@hHauBq' def init_api(): client = BackendApplicationClient(client_id=client_id) oauth_session = OAuth2Session(client=client) token = oauth_session.fetch_token( token_url = token_url, client_id = client_id, client_secret = client_secret ) oauth = OAuth2(client_id=client_id, client=client, token=token) api = jsonapi_requests.orm.OrmApi.config({ 'API_ROOT': api_root, 'AUTH': oauth, 'TIMEOUT': 1, }) jsonapi_requests.configuration.default = api return api api = init_api() MyMeta.set_api(api) # these have to be defined after MyMeta.api is set for the correct value to be inherited from orm.log import * from orm.asset import * from orm.quantity import * from orm.taxonomy import *