Login Session
No credit card required
Login Session
No credit card required
Get localStorage, sessionStorage and cookies from logins for usage in other actors.
You can access the Login Session programmatically from your own JavaScript applications by using the Apify API. You can also choose the language preference from below. To use the Apify API, you’ll need an Apify account and your API token, found in Integrations settings in Apify Console.
1import { ApifyClient } from 'apify-client';
2
3// Initialize the ApifyClient with your Apify API token
4// Replace the '<YOUR_API_TOKEN>' with your token
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9// Prepare Actor input
10const input = {
11 "userAgent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36",
12 "maxRequestRetries": 0,
13 "sessionConfig": {
14 "storageName": "login-sessions",
15 "maxAgeSecs": 3600,
16 "maxUsageCount": 100,
17 "maxPoolSize": 100
18 },
19 "steps": [
20 {
21 "username": {
22 "selector": "input#email"
23 },
24 "password": {
25 "selector": "input#pass"
26 },
27 "submit": {
28 "selector": "input[type=\"submit\"]"
29 },
30 "failed": {
31 "selector": "[role=\"alert\"]"
32 },
33 "waitForMillis": 5000
34 }
35 ],
36 "cookieDomains": [],
37 "gotoTimeout": 30,
38 "proxyConfiguration": {
39 "useApifyProxy": true
40 },
41 "extraUrlPatterns": []
42};
43
44// Run the Actor and wait for it to finish
45const run = await client.actor("pocesar/login-session").call(input);
46
47// Fetch and print Actor results from the run's dataset (if any)
48console.log('Results from dataset');
49console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
50const { items } = await client.dataset(run.defaultDatasetId).listItems();
51items.forEach((item) => {
52 console.dir(item);
53});
54
55// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs
Login Session API in JavaScript
The Apify API client for JavaScript is the official library that allows you to use Login Session API in JavaScript or TypeScript, providing convenience functions and automatic retries on errors.
Install the apify-client
npm install apify-client
Other API clients include:
Actor Metrics
7 monthly users
-
6 stars
20% runs succeeded
Created in Feb 2020
Modified 4 years ago