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

Add utility to read OAuth 2 token from file #318

Closed
atc0005 opened this issue Nov 17, 2022 · 1 comment · Fixed by #346
Closed

Add utility to read OAuth 2 token from file #318

atc0005 opened this issue Nov 17, 2022 · 1 comment · Fixed by #346
Assignees
Milestone

Comments

@atc0005
Copy link
Owner

atc0005 commented Nov 17, 2022

Overview

Provide a small CLI tool that can read an OAuth 2 token from a specified file. The idea is that another tool would be called via cron periodically to obtain an initial token or replace an existing one and that this one would read that token and emit it via stdout.

The assumption is that the input file would be in JSON format containing all relevant fields from an OAuth 2 token.

As a potential later enhancement, the tool could add support for parsing a plain text file in order to perform cleanup (e.g., removing any stray single or double quotes).

Input JSON format

For reference, here is a curl command used to fetch a token:

curl https://login.microsoftonline.com/TENAT_ID_HERE/oauth2/v2.0/token -X POST -H "Content-type: application/x-www-form-urlencoded" -d "client_id=CLIENT_ID_HERE&scope=https%3A%2F%2Foutlook.office365.com%2F.default&grant_type=client_credentials&username=me@example.com&client_secret=CLIENT_SECRET_HERE"

and the "pretty printed" JSON response:

{
    "token_type": "Bearer",
    "expires_in": 3599,
    "ext_expires_in": 3599,
    "access_token": "TOKEN_HERE"
}

References

@atc0005 atc0005 added enhancement New feature or request auth/oauth2 labels Nov 17, 2022
@atc0005 atc0005 added this to the Next Feature Release milestone Nov 17, 2022
@atc0005 atc0005 self-assigned this Nov 17, 2022
@atc0005 atc0005 changed the title Add utility to read OAuth 2 tokens from file Add utility to read OAuth 2 token from file Nov 17, 2022
@atc0005 atc0005 modified the milestones: v0.5.0, Next Feature Release Nov 24, 2022
@atc0005
Copy link
Owner Author

atc0005 commented Nov 26, 2022

The JSON response doesn't indicate a specific time, but rather a duration. We know from the time the token was received that we have approximately 3599 seconds remaining before the token is invalid. How we track that time is an implementation detail.

One way that comes to mind is a field in a SQLite database table, but a simpler approach is likely to be a mod date/time on a written file. Read the metadata of an input JSON file and refuse to proceed further if the token is determined to be expired.

atc0005 added a commit that referenced this issue Nov 28, 2022
- Add utility to obtain OAuth 2 token via Client Credentials flow
- Add utility to read OAuth 2 token from file
- README updates
  - add coverage for new tools
  - misc fixes for previous tooling
- Add automatic retry functionality for OAuth2 token retrieval step
  used by list-emails CLI app and OAuth2-based monitoring plugin
- Add winres config to xoauth2 tool (and to new "Fetcher" tools)

refs GH-318
refs GH-319
atc0005 added a commit that referenced this issue Nov 28, 2022
- Add utility to obtain OAuth 2 token via Client Credentials flow
- Add utility to read OAuth 2 token from file
- README updates
  - add coverage for new tools
  - misc fixes for previous tooling
- Add automatic retry functionality for OAuth2 token retrieval step
  used by list-emails CLI app and OAuth2-based monitoring plugin
- Add winres config to xoauth2 tool (and to new "Fetcher" tools)

refs GH-318
refs GH-319
atc0005 added a commit that referenced this issue Nov 28, 2022
- Add utility to obtain OAuth 2 token via Client Credentials flow
- Add utility to read OAuth 2 token from file
- README updates
  - add coverage for new tools
  - misc fixes for previous tooling
- Add automatic retry functionality for OAuth2 token retrieval step
  used by list-emails CLI app and OAuth2-based monitoring plugin
- Add winres config to xoauth2 tool (and to new "Fetcher" tools)

refs GH-318
refs GH-319
atc0005 added a commit that referenced this issue Nov 28, 2022
- Add utility to obtain OAuth 2 token via Client Credentials flow
- Add utility to read OAuth 2 token from file
- README updates
  - add coverage for new tools
  - misc fixes for previous tooling
- Add automatic retry functionality for OAuth2 token retrieval step
  used by list-emails CLI app and OAuth2-based monitoring plugin
- Add winres config to xoauth2 tool (and to new "Fetcher" tools)

refs GH-318
refs GH-319
atc0005 added a commit that referenced this issue Nov 28, 2022
- Add utility to obtain OAuth 2 token via Client Credentials flow
- Add utility to read OAuth 2 token from file
- README updates
  - add coverage for new tools
  - misc fixes for previous tooling
- Add automatic retry functionality for OAuth2 token retrieval step
  used by list-emails CLI app and OAuth2-based monitoring plugin
- Add winres config to xoauth2 tool (and to new "Fetcher" tools)

refs GH-318
refs GH-319
atc0005 added a commit that referenced this issue Nov 28, 2022
- Add utility to obtain OAuth 2 token via Client Credentials flow
- Add utility to read OAuth 2 token from file
- README updates
  - add coverage for new tools
  - misc fixes for previous tooling
- Add automatic retry functionality for OAuth2 token retrieval step
  used by list-emails CLI app and OAuth2-based monitoring plugin
- Add winres config to xoauth2 tool (and to new "Fetcher" tools)

refs GH-318
refs GH-319
atc0005 added a commit that referenced this issue Nov 28, 2022
- Add utility to obtain OAuth 2 token via Client Credentials flow
- Add utility to read OAuth 2 token from file
- README updates
  - add coverage for new tools
  - misc fixes for previous tooling
- Add automatic retry functionality for OAuth2 token retrieval step
  used by list-emails CLI app and OAuth2-based monitoring plugin
- Add winres config to xoauth2 tool (and to new "Fetcher" tools)

refs GH-318
refs GH-319
atc0005 added a commit that referenced this issue Nov 28, 2022
- Add utility to obtain OAuth 2 token via Client Credentials flow
- Add utility to read OAuth 2 token from file
- README updates
  - add coverage for new tools
  - misc fixes for previous tooling
- Add automatic retry functionality for OAuth2 token retrieval step
  used by list-emails CLI app and OAuth2-based monitoring plugin
- Add winres config to xoauth2 tool (and to new "Fetcher" tools)

refs GH-318
refs GH-319
atc0005 added a commit that referenced this issue Nov 28, 2022
- Add utility to obtain OAuth 2 token via Client Credentials flow
- Add utility to read OAuth 2 token from file
- README updates
  - add coverage for new tools
  - misc fixes for previous tooling
- Add automatic retry functionality for OAuth2 token retrieval step
  used by list-emails CLI app and OAuth2-based monitoring plugin
- Add winres config to xoauth2 tool (and to new "Fetcher" tools)

refs GH-318
refs GH-319
atc0005 added a commit that referenced this issue Nov 28, 2022
- Add utility to obtain OAuth 2 token via Client Credentials flow
- Add utility to read OAuth 2 token from file
- README updates
  - add coverage for new tools
  - misc fixes for previous tooling
- Add automatic retry functionality for OAuth2 token retrieval step
  used by list-emails CLI app and OAuth2-based monitoring plugin
- Add winres config to xoauth2 tool (and to new "Fetcher" tools)

refs GH-318
refs GH-319
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant