Check your version

This video covers a topic in Drupal 7 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 7, but we consider it archived.

Alternate resources: 

Making Authenticated Requests with cURL

Video loading...

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:01
    Making Authenticated Requests with cURL
  • 0:03
    Joe Shindelar
  • 0:08
    JOE SHINDELAR: In this lesson, we'll be using cURL again in order
  • 0:11
    to demonstrate the somewhat complicated process of exchanging
  • 0:14
    a username and password for an authenticated session and a CSRF
  • 0:19
    token.
  • 0:20
    Then, we'll add the session data we retrieved into the header
  • 0:24
    of other requests to the API so that services can authenticate
  • 0:28
    our client and treat the request as if it's
  • 0:31
    being made by an authenticated user.

Making Authenticated Requests with cURL

Loading...

In this lesson Joe walks through making authenticated requests to our API with cURL. Although cURL can be a bit verbose when making authenticated requests it serves as a good way to talk about all the headers that are a required and a lowest common denominator for how you could accomplish authentication in just about any language or application.

Example commands

curl http://services-demo.lan/api/v1/user/login -d '{"name":"admin","pass":"admin"}' -H "Content-type: application/json" -H "Accept: application/json"

curl http://services-demo.lan/api/v1/system/connect -X POST

curl http://services-demo.lan/api/v1/system/connect -H "Cookie: SESS60f8c5b86739b7e326223b4ef35867b2=A86XHGJWlnDcMOGcArbOT-qHrsIi5P2NrcoNTXwWluw" -H "X-CSRF-Token: T77haXwD7JKOJsBlKP3p3kLbjQO96bQWvGJAE1_PUZM" -X POST

curl http://services-demo.lan/api/v1/user/login -X POST -H "Content-type: application/json" -H "Accept: application/json"

Additional resources:
There are no resources for this video. If you believe there should be, please contact us.