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

Store OAuth global variables on initial auth #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

f0e
Copy link

@f0e f0e commented Jul 31, 2024

I noticed when setting up my own OAuth config storage that fetching the values of core.OAUTH_REFRESH and core.OAUTH_EXPIRES_AT after running trakt.init wasn't working. Turns out that's because while they were being set, they were only being set locally. I made them global in oauth_auth() and get_device_token() and it's working now.

Copy link

coderabbitai bot commented Jul 31, 2024

Walkthrough

The recent changes enhance the OAuth authentication process by introducing two new global variables, OAUTH_REFRESH and OAUTH_EXPIRES_AT, within the oauth_auth and get_device_token functions. This expansion aims to improve token management, allowing for better handling of refresh tokens and expiration times while maintaining the existing logic of these functions.

Changes

File Change Summary
trakt/core.py Modified global variable declarations in oauth_auth and get_device_token to include OAUTH_REFRESH and OAUTH_EXPIRES_AT for enhanced OAuth token management.

Poem

🐇 In the meadow, bright and wide,
Tokens dance and leap with pride.
Refreshing dreams in sunny light,
Expiration’s fears take flight.
With every hop, our code does sing,
OAuth magic, let’s take wing! 🌼✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3c4a5fe and 0b1e118.

Files selected for processing (1)
  • trakt/core.py (2 hunks)
Additional comments not posted (2)
trakt/core.py (2)

262-262: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to get_device_token are correctly handling the new global variables.

Verification successful

The new global variables OAUTH_REFRESH and OAUTH_EXPIRES_AT are correctly handled in the codebase.

The search results show that these variables are being set and used appropriately in trakt/core.py.

  • OAUTH_REFRESH and OAUTH_EXPIRES_AT are set and accessed in multiple locations within the file.
  • The global variables are integrated into the logic of the authentication process.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `get_device_token` are correctly handling the new global variables.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type python -A 5 $'get_device_token'

Length of output: 71


Script:

#!/bin/bash
# Description: Verify all function calls to `get_device_token` are correctly handling the new global variables.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type py -A 5 $'get_device_token'

Length of output: 1320


Script:

#!/bin/bash
# Description: Verify the handling of the new global variables `OAUTH_REFRESH` and `OAUTH_EXPIRES_AT`.

# Test: Search for the usage of `OAUTH_REFRESH` and `OAUTH_EXPIRES_AT`. Expect: Occurrences of the new global variables.
rg --type py 'OAUTH_REFRESH|OAUTH_EXPIRES_AT'

Length of output: 2298


182-182: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to oauth_auth are correctly handling the new global variables.

Verification successful

The new global variables are correctly handled in the codebase.

The global variables OAUTH_REFRESH and OAUTH_EXPIRES_AT are properly set and used in various functions, including oauth_auth.

  • trakt/core.py: Multiple occurrences show correct handling of OAUTH_REFRESH and OAUTH_EXPIRES_AT.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `oauth_auth` are correctly handling the new global variables.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type python -A 5 $'oauth_auth'

Length of output: 65


Script:

#!/bin/bash
# Description: Verify all function calls to `oauth_auth` are correctly handling the new global variables.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg 'oauth_auth' -A 5

Length of output: 911


Script:

#!/bin/bash
# Description: Extract the full definition of `oauth_auth` and its usage in the codebase.

# Extract the full definition of `oauth_auth`.
rg 'def oauth_auth' -A 20

# Extract all occurrences of `oauth_auth` usage in the codebase.
rg 'oauth_auth' -A 5

Length of output: 2284


Script:

#!/bin/bash
# Description: Verify the usage of the new global variables OAUTH_REFRESH and OAUTH_EXPIRES_AT in the codebase.

# Search for occurrences of OAUTH_REFRESH in the codebase.
rg 'OAUTH_REFRESH' -A 5

# Search for occurrences of OAUTH_EXPIRES_AT in the codebase.
rg 'OAUTH_EXPIRES_AT' -A 5

Length of output: 10279

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.

1 participant