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

Improve str(OAuthTokenResponse) #640

Merged
merged 1 commit into from
Nov 4, 2022

Conversation

sirosen
Copy link
Member

@sirosen sirosen commented Nov 3, 2022

This makes the str() of an oauth response object more verbose, clarifying that by_resource_server is a field (not the set of top-level keys) and including mention of id_token. The output is also now more YAML-like, and not just an undecorated JSON dump.

In practice, the id_token can be very long, so this implementation truncates it to the first 10 chars and notes it as ... (truncated).

No other fields are added to the stringifier as of yet.

resolves #639


Example output (with tokens redacted):

OAuthTokenResponse:
  id_token: eyJhbGciOi... (truncated)
  by_resource_server:
    {
      "auth.globus.org": {
        "scope": "openid email profile",
        "access_token": "REDACTED",
        "refresh_token": null,
        "token_type": "Bearer",
        "expires_at_seconds": 1667661839,
        "resource_server": "auth.globus.org"
      },
      "transfer.api.globus.org": {
        "scope": "urn:globus:auth:scope:transfer.api.globus.org:all",
        "access_token": "REDACTED",
        "refresh_token": null,
        "token_type": "Bearer",
        "expires_at_seconds": 1667661839,
        "resource_server": "transfer.api.globus.org"
      }
    }

This makes the str() of an oauth response object more verbose,
clarifying that `by_resource_server` is a field (not the set of
top-level keys) and including mention of `id_token`. The output is
also now more YAML-like, and not just an undecorated JSON dump.

In practice, the `id_token` can be very long, so this implementation
truncates it to the first 10 chars and notes it as `... (truncated)`.

No other fields are added to the stringifier as of yet.

resolves globus#639
@sirosen sirosen requested a review from kurtmckee November 3, 2022 15:36
@sirosen sirosen merged commit 91c4f29 into globus:main Nov 4, 2022
@sirosen sirosen deleted the update-oauth-token-response-str branch November 4, 2022 19:08
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.

Confusing __str__() implementation for OAuthTokenResponse
2 participants