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

Not saving new credentials file to path when generating new refresh_token #10

Open
leassaf opened this issue Mar 27, 2022 · 1 comment

Comments

@leassaf
Copy link

leassaf commented Mar 27, 2022

When creating new credentials with new refresh_token, you set is_access_token_expired to False, and than it doesn't save it to the json file path. so one repeats generating new credentials over and over again.

In file credentials.py added after the first if statement:

def validate_token(self) -> None:
        """Validates the access token and refresh token.

        ### Overview
        ----
        A TD Ameritrade Access token is only valid for 30 minutes,
        and a TD Ameritrade Refresh token is only valid for 90 days.
        When an access token expires, a new one is retrieved using the
        refresh token. If the refresh token is expired the oAuth workflow
        starts again.
        """

        if self.is_refresh_token_expired:
            print("Refresh Token Expired, initiating oAuth workflow...")
            self.from_workflow()

            # save to json file
            if self._loaded_from_file:
                self.to_credential_file(file_path=self._file_path)

        if self.is_access_token_expired:
            print("Access Token Expired, refreshing access token...")
            token_dict = self.grab_access_token()
            self.from_token_dict(token_dict=token_dict)

            if self._loaded_from_file:
                self.to_credential_file(file_path=self._file_path)
@leassaf leassaf changed the title not saving new credentials file to path when generating new refresh_token Not saving new credentials file to path when generating new refresh_token Mar 27, 2022
@monsieur40a
Copy link

I fixed this with the auth-refactor branch. I have a variable called something like first_run that saves the json.

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

No branches or pull requests

2 participants