-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add API Token authentication #20
Conversation
new configuration options: 'email': the account's email 'api_token': the account's api token
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the overall addition here.
Can you provide some gists of runs with the different configurations and address some of the specific comments I left? Preferably with redacted cat
s of the config files for each run?
tap_zendesk/__init__.py
Outdated
creds.update({ | ||
"oauth_token": oauth_args.config['access_token'], | ||
}) | ||
except: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this and the other except:
handle a more specific error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure will do.
Thanks for the comments, I'll fix the issues and provide a sample config/runs for you shortly. |
- add INFO log for the used auth - fixed bare except: clauses - make sure the OAuth has precedence
…ndesk into add-api-token-auth
@timvisher I think I solved most issues, please do another review. Here's a gist of runs: https://gist.github.com/micaelbergeron/50493d87ba711389143fcda3645ed88a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good.
I'd like to see a bit more documentation and slightly different structure to the auth calls. Also I really don't want to catch Exception
.
tap_zendesk/__init__.py
Outdated
"access_token" | ||
] | ||
|
||
API_CONFIG_KEYS = REQUIRED_CONFIG_KEYS + [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a similar comment here about the mutual exclusivity and preference ordering of these two config sections would be nice.
tap_zendesk/__init__.py
Outdated
return client | ||
except ZenpyException: | ||
LOGGER.error("OAuth authentication failed.") | ||
except Exception: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a ValueError
or other kind of specific exception? Could we not catch Exception
here by just checking if the args contain a particular key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parse_args
will raise an Exception
(see https://github.com/singer-io/singer-python/blob/dfad8fc467704900e0f268a05919bd34976aaa0e/singer/utils.py#L150) if the required_keys
are not present.
So we can't use parse_args
to validate that the config is there without catching an Exception
when the config is not there.
I'll do the check manually then.
- add some documentation - wording - remove dead code, Zenpy doens't raise on failed authentication
3301d9c
to
ba26107
Compare
@timvisher I think this is ready for another review. Thanks for your help :D Here's the new output: Using OAuth
Using API Token
When something is wrong
I've removed the |
👍Merging this -- thanks for contributing @micaelbergeron! |
This PR add the configuration options to either auth using OAuth (current behavior) or API Tokens as Zenpy supports both configurations.