-
Notifications
You must be signed in to change notification settings - Fork 2
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -311,7 +311,8 @@ const createMainWindow = async () => { | |
|
||
try { | ||
await scraper.login(username, password, email); | ||
return { success: true }; | ||
const cookies = await scraper.getCookies(); | ||
return { success: true, cookies }; | ||
Comment on lines
313
to
+315
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} catch (error) { | ||
console.error('Twitter login error:', error); | ||
return { success: false, error: error.message }; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,18 +118,20 @@ const SetupYourAgentForm = ({ serviceTemplate }: SetupYourAgentFormProps) => { | |
|
||
// validate the twitter credentials | ||
setSubmitButtonText('Validating Twitter credentials...'); | ||
const isTwitterCredentialsValid = electronApi?.validateTwitterLogin | ||
? await validateTwitterCredentials( | ||
values.xEmail, | ||
values.xUsername, | ||
values.xPassword, | ||
electronApi.validateTwitterLogin, | ||
) | ||
: false; | ||
const { isValid: isTwitterCredentialsValid, cookies } = | ||
electronApi?.validateTwitterLogin | ||
? await validateTwitterCredentials( | ||
values.xEmail, | ||
values.xUsername, | ||
values.xPassword, | ||
electronApi.validateTwitterLogin, | ||
) | ||
: { isValid: false }; | ||
setTwitterCredentialsValidationStatus( | ||
isTwitterCredentialsValid ? 'valid' : 'invalid', | ||
); | ||
if (!isTwitterCredentialsValid) return; | ||
if (!cookies) return; | ||
|
||
// wait for agent setup to complete | ||
setSubmitButtonText('Setting up agent...'); | ||
|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this will write it in the format of:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's only a key named There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
}, | ||
GENAI_API_KEY: { | ||
...serviceTemplate.env_variables.GENAI_API_KEY, | ||
value: values.geminiApiKey, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Cookies returned by agent-twitter-client | ||
* when log in | ||
*/ | ||
export type XCookie = { | ||
key: string; | ||
value: string; | ||
domain?: string; | ||
path?: string; | ||
secure?: boolean; | ||
httpOnly?: boolean; | ||
sameSite?: string; | ||
expires?: string; | ||
}; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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:
The login wont be called again?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)