Skip to content

Instantly share code, notes, and snippets.

@cristiroma
Created September 6, 2019 10:25
Show Gist options
  • Save cristiroma/6099505104f7b6a4753f9028d92ec867 to your computer and use it in GitHub Desktop.
Save cristiroma/6099505104f7b6a4753f9028d92ec867 to your computer and use it in GitHub Desktop.
Drupal Log in using cURL command line
SITE="https://www.website.com"
USER="[email protected]"
PASS="password"
# Log in and save session cookies to cookies.txt
curl -c ./cookies.txt -L -X POST $SITE/user/login -d "name=$USER&pass=$PASS&form_id=user_login_form&op=Log In"
# Make authenticated requests
curl -b cookie.txt -X GET $SITE/admin/config/development/performance
@cristiroma
Copy link
Author

cristiroma commented Oct 8, 2019

Raise error

curl -X POST --form name%5B0%5D="" --form form_id=user_pass -- https://example.com/user/password?name%5B0%5D
curl -X POST --form form_id=user_pass https://example.com/user/password?name%5B0%5D=""

@stefanbutura
Copy link

cookies.txt format

# Netscape HTTP Cookie File
# https://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

domain.com      FALSE   /       FALSE   0       WSS_KeepSessionAuthenticated    {xxx}
domain.com      FALSE   /       FALSE   0       WSS_FullScreenMode      false
domain.com      FALSE   /SitePages      FALSE   0       stsSyncIconPath
domain.com      FALSE   /SitePages      FALSE   0       stsSyncAppName  Client
domain.com      FALSE   /SitePages      FALSE   0       databaseBtnDesc 0
domain.com      FALSE   /SitePages      FALSE   0       databaseBtnText 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment