# Amazon Login Actor (`laisidata/amazon-login-actor`) Actor

Performs Amazon browser login with fingerprint and returns fresh cookies. Called by the reviews scraper when cookies expire.

- **URL**: https://apify.com/laisidata/amazon-login-actor.md
- **Developed by:** [agi](https://apify.com/laisidata) (community)
- **Categories:** E-commerce
- **Stats:** 11 total users, 6 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.15 / actor start

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Amazon Login Actor

An Apify Actor that performs Amazon browser login with a simulated Windows Chrome fingerprint and returns fresh session cookies. Called by the [Amazon Reviews Scraper](../apify/) when scraped cookies expire.

### How it works

1. Generates a **Windows Chrome fingerprint** via `browserforge` (part of the Crawlee ecosystem) — User-Agent, navigator properties, screen dimensions all consistent with a real Windows desktop Chrome session.
2. Launches **headless Chromium** (Playwright, managed by Crawlee) with:
   - `--password-store=basic`, `--disable-features=PasswordManager,WebAuthnUI,WebAuthentication` to suppress password-save dialogs and Windows security prompts
   - WebAuthn / Credentials API blocked via `add_init_script`
   - Persistent context (`launch_persistent_context`) for static resource caching
3. Navigates the **Amazon login flow** (email → password → 2FA → challenges), same logic as `gologin-worker`.
4. Extracts **all cookies** from the browser context and outputs them.

### Input

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `account` | string | yes | Amazon account email |
| `password` | string | yes | Amazon account password |
| `country` | string | yes | Marketplace country code (e.g. `US`, `GB`, `DE`) |
| `faToken` | string | no | TOTP shared secret for 2FA. Leave empty if the account has no 2FA. |

### Output

Saved to the run's key-value store under key `OUTPUT`:

```json
{
  "status": "success",
  "country": "US",
  "domain": "www.amazon.com",
  "cookie_count": 42,
  "cookies": [
    {
      "name": "session-id",
      "value": "...",
      "domain": ".amazon.com",
      "path": "/",
      "expires": 1234567890.0,
      "httpOnly": true,
      "secure": true,
      "sameSite": "None"
    }
  ]
}
```

Possible `status` values: `success`, `suspended`, `failed`.

On failure, `error` and `message` fields are included (plus `logs` for debugging on dev accounts).

### Logging

Only developer accounts see full stdout logs (`config.is_dev_account()` — based on `DEV_USER_IDS`, `CRAWLER_VERBOSE_LOG`, `dev` build tag, or local run without `ACTOR_RUN_ID`). All other runs output only public milestones. Sensitive fields (password, 2FA token, cookies) are redacted in logs regardless of account type.

### Integration with the Reviews Scraper

The scraper calls this actor via `Actor.call()` when it detects an expired session (`SessionExpiredError`):

1. Scraper acquires a session from the server → gets cookies + credentials
2. Scraper scrapes with those cookies
3. If `SessionExpiredError` → scraper calls this login actor with the credentials
4. Login actor returns fresh cookies → scraper retries scraping once
5. If the retry still fails → **no further retry**, the ASIN is marked as failed

To enable, set the `LOGIN_ACTOR_ID` environment variable on the scraper actor (to this login actor's ID). If unset, the scraper falls back to the original server-based cookie retry loop.

### Development

```bash
## Install dependencies
pip install -r requirements.txt
playwright install chromium

## Run locally
python -m src
```

# Actor input Schema

## `account` (type: `string`):

Amazon account email address.

## `password` (type: `string`):

Amazon account password.

## `country` (type: `string`):

Marketplace country code.

## `faToken` (type: `string`):

TOTP shared secret used to generate 2FA codes. Leave empty if the account has no 2FA.

## Actor input object example

```json
{
  "account": "",
  "password": "",
  "country": "US",
  "faToken": ""
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("laisidata/amazon-login-actor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("laisidata/amazon-login-actor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call laisidata/amazon-login-actor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,laisidata/amazon-login-actor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/RQkcCUQFOkcrODbAM/builds/ZFBEv4uREBfsXs4uf/openapi.json
