Skip to content
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

Fixes cached tokens #252

Merged
merged 2 commits into from
Sep 20, 2021
Merged

Fixes cached tokens #252

merged 2 commits into from
Sep 20, 2021

Conversation

marioortizmanero
Copy link
Collaborator

@marioortizmanero marioortizmanero commented Sep 19, 2021

Description

This fixes:

  • prompt_for_user, which failed when read_token_cache returned and error. The problem here is that we are expecting an error in case the cache file isn't found (FileNotFoundError). We just want to ignore it, but it used ?, which caused an early return. So the match expression just accepts Ok(Some()) now.
  • read_token_cache for OAuth clients didn't check the config. Whoops

I also updated the docs to make them more exhaustive.

Motivation and Context

This was caused by #250

Dependencies

None

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • This change requires a documentation update

How Has This Been Tested?

If you remove all cached tokens in your main directory and try to run any example it won't work. Now it does. This is because prompt_user_token returned FileNotFound and propagated. For example try with:

cargo run --example auth_code --features="env-file,cli"

/// available or the JSON is malformed). It may return `Ok(None)` if:
///
/// * The read token is expired
/// * The cached token is disabled in the config
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems you are missing one condition that

/// * Its scopes don't match with the current client

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, I messed up the docs. Should be fine now

@ramsayleung ramsayleung merged commit ba98d32 into master Sep 20, 2021
@marioortizmanero marioortizmanero deleted the fix-token-read branch September 20, 2021 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants