Tweaks for xero oauth (#11)

* Tweaks for xero oauth

* Better docstring
This commit is contained in:
jbirddog 2022-10-18 10:43:39 -04:00 committed by GitHub
parent 049fa2fbb9
commit 3a927e11de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 10 deletions

7
app.py
View File

@ -59,8 +59,7 @@ def list_commands():
def auth_handler(plugin_display_name, auth_name, params): def auth_handler(plugin_display_name, auth_name, params):
auth = PluginService.auth_named(plugin_display_name, auth_name) auth = PluginService.auth_named(plugin_display_name, auth_name)
if auth is not None: if auth is not None:
handler_params = auth.filtered_params(params) app_description = auth().app_description(app.config)
app_description = auth(**handler_params).app_description()
# TODO right now this assumes Oauth. # TODO right now this assumes Oauth.
# would need to expand if other auth providers are used # would need to expand if other auth providers are used
@ -89,8 +88,8 @@ def do_auth(plugin_display_name, auth_name):
# TODO factor into handler # TODO factor into handler
# TODO namespace the keys # TODO namespace the keys
session["client_id"] = params["client_id"] session["client_id"] = app.config["XERO_CLIENT_ID"]
session["client_secret"] = params["client_secret"] session["client_secret"] = app.config["XERO_CLIENT_SECRET"]
oauth_redirect_url = url_for( oauth_redirect_url = url_for(
"auth_callback", "auth_callback",

View File

@ -4,18 +4,17 @@
class OAuth: class OAuth:
"""OAuth.""" """OAuth."""
def __init__(self, client_id: str, client_secret: str): def __init__(self):
"""__init__.""" """__init__."""
self.client_id = client_id pass
self.client_secret = client_secret
def app_description(self): def app_description(self, config):
"""App_description.""" """App_description."""
return { return {
"name": "xero", "name": "xero",
"version": "2", "version": "2",
"client_id": self.client_id, "client_id": config["XERO_CLIENT_ID"],
"client_secret": self.client_secret, "client_secret": config["XERO_CLIENT_SECRET"],
"endpoint_url": "https://api.xero.com/", "endpoint_url": "https://api.xero.com/",
"authorization_url": "https://login.xero.com/identity/connect/authorize", "authorization_url": "https://login.xero.com/identity/connect/authorize",
"access_token_url": "https://identity.xero.com/connect/token", "access_token_url": "https://identity.xero.com/connect/token",
@ -25,6 +24,7 @@ class OAuth:
"accounting.contacts accounting.attachments assets projects", "accounting.contacts accounting.attachments assets projects",
} }
# TODO reconsider how this is working
@staticmethod @staticmethod
def filtered_params(params): def filtered_params(params):
"""Filtered_params.""" """Filtered_params."""