Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Raise Error if Credentials are Invalid #10

@jambonrose

Description

@jambonrose

Hi,
If there's a credential mismatch in either the ~/.gbdx-config INI file or any of the environment variables (GBDX_USERNAME, GBDX_PASSWORD, GBDX_CLIENT_ID, and GBDX_CLIENT_SECRET) then gbdxtools will fail cryptically or silently.

For instance, in the event a typo has been introduced in GBDX_PASSWORD, then the program will tell you to create ~/.gbdx-config (rather than tell you your credentials are wrong). In the event a typo is introduced in this config, then the program returns Invalid credentials or incorrectly formated config file at ~/.gbdx-config. It's not clear what the problem is.

Attempting to run the code again will yield no output, even during failures. A repeat call to session_from_kwargs with different credentials therefore seems to work, even when it does not. Using any code after that raises Nonetype errors, as the session is None.

In the event credentials fail, the user should be warned of the failure explicitly.

Using logging, it looks as though the error raised by fetch_token (in any of the session calls in this project) is oauthlib.oauth2.rfc6749.errors.MissingTokenError, which is a rather strange error to raise when an HTTP 401 is returned (particularly given that this is an attempt to get a token). It would be nice to wrap these calls with try...except blocks to catch this error and inform the user of the probable failure in their config.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions