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

feat: saves twitter cookies to envs #598

Merged
merged 4 commits into from
Dec 17, 2024

Conversation

Tanya-atatakai
Copy link
Collaborator

Proposed changes

save twitter cookies stringified json to env variables so it can be then processed by BE

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Comment on lines 313 to +315
await scraper.login(username, password, email);
return { success: true };
const cookies = await scraper.getCookies();
return { success: true, cookies };
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the call to scraper.login always use the password? I think we first should check whether we already have the cookies.

Copy link
Member

Choose a reason for hiding this comment

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

probably we can check if the cookies already exists in that path (TWIKIT_COOKIES_PATH), but I guess (correct me if I'm wrong) this logic is only executed once, at the time of registering?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's what it should happen, but not what it is happening. On validation failure it tries again. Or what if the user closes the app before starting the agent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is FE code only @dvilelaf. this is for the form where a user first time enters their credentials, we only once validate them (by using scraper.login) and write the cookies recieved. we don't allow to change that, so it won't be called ever again from FE

Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand that. So if a user:

  • Opens Pearl for the first time
  • Fills in the form and data is validated
  • User closes the app
  • User re-opens the app

The login wont be called again?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I say this because this morning I saw 2 succesfull logins being made from the validation form.

Copy link
Collaborator Author

@Tanya-atatakai Tanya-atatakai Dec 16, 2024

Choose a reason for hiding this comment

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

not from FE side. but I assume from BE it will - when starting an agent. and here @OjusWiZard might need to update that (or correct me)

Comment on lines 313 to +315
await scraper.login(username, password, email);
return { success: true };
const cookies = await scraper.getCookies();
return { success: true, cookies };
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the call to scraper.login always use the password? I think we first should check whether we already have the cookies.

@@ -151,6 +153,10 @@ const SetupYourAgentForm = ({ serviceTemplate }: SetupYourAgentFormProps) => {
...serviceTemplate.env_variables.TWIKIT_PASSWORD,
value: values.xPassword,
},
TWIKIT_COOKIES: {
...serviceTemplate.env_variables.TWIKIT_COOKIES,
value: cookies,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this will write it in the format of:

'{"guest_id_marketing":"111","guest_id_ads":"111","personalization_id":"111","guest_id":"111","kdt":"111","twid":"111","ct0":"111","auth_token":"111","att":"111"}'

Copy link
Member

Choose a reason for hiding this comment

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

there's only a key named _twitter_sess missing when I compare it to the cookies that are generated by the BE validation. @dvilelaf do you know if that will cause any issues?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is needed, but I'm not 100% sure. I definitely have it in my cookies

@Tanya-atatakai Tanya-atatakai merged commit aad5d7f into fix/meme-staging Dec 17, 2024
4 of 5 checks passed
@Tanya-atatakai Tanya-atatakai deleted the tanya/twitter-cookies branch December 17, 2024 08:48
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.

4 participants