update login code examples (#3015)

This commit is contained in:
Shuchang Zheng
2025-07-22 06:38:08 -07:00
committed by GitHub
parent 7c5a799478
commit 6dcf07c241
3 changed files with 85 additions and 25 deletions

View File

@@ -25,10 +25,27 @@ RETRY_RUN_WEBHOOK_CODE_SAMPLE = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY")
await skyvern.retry_run_webhook(run_id="tsk_v2_123")
"""
LOGIN_CODE_SAMPLE = """from skyvern import Skyvern
LOGIN_CODE_SAMPLE_SKYVERN = """# Login with password saved in Skyvern
from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY")
await skyvern.login(workflow_id="wpid_123", parameters={"parameter1": "value1", "parameter2": "value2"})
await skyvern.login(credential_id="cred_123")
"""
LOGIN_CODE_SAMPLE_BITWARDEN = """# Login with password saved in Bitwarden
from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY")
# Login with a Bitwarden collection and website url filter
await skyvern.login(bitwarden_collection_id="BITWARDEN COLLECTION ID", url_filter="https://example.com")
# Login with a Bitwarden item
await skyvern.login(bitwarden_item_id="BITWARDEN ITEM ID")
"""
LOGIN_CODE_SAMPLE_ONEPASSWORD = """# Login with password saved in 1Password
from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY")
await skyvern.login(onepassword_vault_id="ONEPASSWORD VAULT ID", onepassword_item_id="ONEPASSWORD ITEM ID")
"""
# Workflows

View File

@@ -7,7 +7,11 @@ from skyvern.config import settings
from skyvern.exceptions import MissingBrowserAddressError
from skyvern.forge import app
from skyvern.forge.sdk.core import skyvern_context
from skyvern.forge.sdk.routes.code_samples import LOGIN_CODE_SAMPLE
from skyvern.forge.sdk.routes.code_samples import (
LOGIN_CODE_SAMPLE_BITWARDEN,
LOGIN_CODE_SAMPLE_ONEPASSWORD,
LOGIN_CODE_SAMPLE_SKYVERN,
)
from skyvern.forge.sdk.routes.routers import base_router
from skyvern.forge.sdk.schemas.organizations import Organization
from skyvern.forge.sdk.services import org_auth_service
@@ -39,7 +43,24 @@ If login is completed, you're successful."""
response_model=WorkflowRunResponse,
openapi_extra={
"x-fern-sdk-method-name": "login",
"x-fern-examples": [{"code-samples": [{"sdk": "python", "code": LOGIN_CODE_SAMPLE}]}],
"x-fern-examples": [
{
"code-samples": [
{
"sdk": "python",
"code": LOGIN_CODE_SAMPLE_SKYVERN,
},
{
"sdk": "python",
"code": LOGIN_CODE_SAMPLE_BITWARDEN,
},
{
"sdk": "python",
"code": LOGIN_CODE_SAMPLE_ONEPASSWORD,
},
]
}
],
},
description="Log in to a website using either credential stored in Skyvern, Bitwarden or 1Password",
summary="Login Task",
@@ -80,8 +101,8 @@ async def login(
yaml_parameters = [
BitwardenLoginCredentialParameterYAML(
key=parameter_key,
collection_id=login_request.collection_id,
item_id=login_request.item_id,
collection_id=login_request.bitwarden_collection_id,
item_id=login_request.bitwarden_item_id,
url=login_request.url,
description="The ID of the bitwarden collection to use for login",
bitwarden_client_id_aws_secret_key="SKYVERN_BITWARDEN_CLIENT_ID",
@@ -93,8 +114,8 @@ async def login(
yaml_parameters = [
OnePasswordCredentialParameterYAML(
key=parameter_key,
vault_id=login_request.vault_id,
item_id=login_request.item_id,
vault_id=login_request.onepassword_vault_id,
item_id=login_request.onepassword_item_id,
)
]