-
Notifications
You must be signed in to change notification settings - Fork 27
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
Missing OAuth configuration error handling #62
Comments
Great observation @bfoz 🙌 I'll add it in! |
@bfoz do you think this would be sufficient? def verify_oauth_config(oauth_config: OAuth1aConfig) -> None:
"""
Validates the OAuth 1.0a configuration parameters.
Checks if all required parameters are set and raises an exception if any are missing.
Parameters:
oauth_config (OAuth1aConfig): The OAuth 1.0a configuration object to validate.
Raises:
ValueError: If any required parameter is missing.
"""
required_params = [
'oauth_rest_url',
'live_session_token_endpoint',
'access_token',
'access_token_secret',
'consumer_key',
'dh_prime',
'encryption_key_fp',
'signature_key_fp',
]
missing_params = [param for param in required_params if getattr(oauth_config, param) is None]
if missing_params:
raise ValueError(f"OAuth1aConfig is missing required parameters: {', '.join(missing_params)}")
required_filepaths = [
'encryption_key_fp',
'signature_key_fp',
]
missing_filepaths = [filepath for filepath in required_filepaths if not Path(getattr(oauth_config, filepath)).exists()]
if missing_filepaths:
raise ValueError(f"OAuth1aConfig's filepaths don't exist: {', '.join(missing_filepaths)}")
return Please try |
I haven't tested this yet, but it looks like the right idea to me. Thanks! |
@bfoz already published this with 0.1.12 👍 give it a spin when you find a minute |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm using the environment variable method to configure OAuth, and it generally works. However, if the user does something dumb, eg. forgets to start the virtual environment that loads the environment variables,
ibind
throws an exception that isn't entirely helpful. It might be nice to catch this and re-raise a more descriptive exception.Obviously this is a just a nice to have, and therefore not a high priority. Thanks for the OAuth support!
The text was updated successfully, but these errors were encountered: