mirror of
https://github.com/j93es/browser-use-oauth.git
synced 2026-06-04 06:51:52 +09:00
[Refactor] 리팩터링
This commit is contained in:
parent
26b40e0e65
commit
bbd2d6d636
20 changed files with 397 additions and 257 deletions
60
lib/agents/login_google/prompt.py
Normal file
60
lib/agents/login_google/prompt.py
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
from pydantic import BaseModel
|
||||
from lib.config import GOOGLE_ID, GOOGLE_PASSWORD
|
||||
|
||||
class LoginGoogleResponse(BaseModel):
|
||||
msg: str | None = None
|
||||
status: str | None = None # "success", "mfa_required", "google_blocked", "sso_not_found", "login_page_not_found", "invalid_credentials"
|
||||
final_url: str | None = None
|
||||
|
||||
login_google_task = f"""
|
||||
You are a web automation agent.
|
||||
|
||||
Your task is to visit the given domain and perform a full login via the **Google SSO button**, following all steps strictly as described below.
|
||||
|
||||
▶ Target: Find a login page inside this domain that allows "Sign in with Google", and use it to complete login via Google.
|
||||
|
||||
Instructions:
|
||||
|
||||
1. If any cookie or privacy popups appear, dismiss or accept them.
|
||||
2. Navigate through the site's UI to find the **login or sign-in page** (e.g., via buttons like "Log In", "Sign In", "Get Started").
|
||||
- Only follow links within the same domain.
|
||||
3. On the login page, look for a clearly labeled **Google SSO button** — typically labeled as:
|
||||
- "Continue with Google"
|
||||
- "Sign in with Google"
|
||||
- or a button with the Google 'G' icon
|
||||
4. Click the **Google login button**.
|
||||
- ⚠️ The Google login flow MUST open in a **new browser tab** (not a new window or popup).
|
||||
- ❌ If the login opens in a new **window** or **popup**, do NOT continue. Immediately stop and return the appropriate status.
|
||||
5. Check if the user is **already logged in to Google and immediately redirected back to the original site** without showing a Google login screen.
|
||||
- ✅ If so, treat the login as successful and return immediately.
|
||||
6. If redirected to the Google login page:
|
||||
- If a **CAPTCHA**, **MFA prompt**, or a request for **ID/password entry** appears, do NOT proceed.
|
||||
- Immediately stop and return the appropriate status.
|
||||
7. If login proceeds without interruptions, wait for redirection back to the original site and record the final URL.
|
||||
|
||||
Credentials to use (only if needed):
|
||||
- Email: {GOOGLE_ID}
|
||||
- Password: {GOOGLE_PASSWORD}
|
||||
|
||||
Constraints:
|
||||
- Do NOT use search engines or guess URLs — only navigate links discoverable from https://example.com
|
||||
- Do NOT use autofill, saved sessions, or cookies.
|
||||
- Do NOT proceed with login if:
|
||||
- The login opens in a new window (only tabs are allowed)
|
||||
- CAPTCHA or MFA appears
|
||||
- ID/password input is required
|
||||
- If the user is already logged in to Google and redirected back automatically, stop there and report success.
|
||||
|
||||
Final Output:
|
||||
Return the result in the following format only:
|
||||
|
||||
```json
|
||||
{{
|
||||
"msg": "Google login completed",
|
||||
"status": "success" | "already_logged_in" | "mfa_required" | "captcha_triggered" | "window_blocked" | "idpw_required" | "google_blocked" | "sso_not_found" | "login_page_not_found",
|
||||
"final_url": "<url_after_login_redirect or empty string>"
|
||||
}}
|
||||
```
|
||||
|
||||
- Return ONLY the JSON object. Do NOT include any explanation, logging, or extra output.
|
||||
"""
|
||||
Loading…
Add table
Add a link
Reference in a new issue