---
title: "View source for Authentication - DreamFactory Wiki"
source: "http://wiki.dreamfactory.com/index.php?action=edit&title=Authentication"
canonical_url: "http://wiki.dreamfactory.com/index.php?action=edit&title=Authentication"
converted_at: "2026-11-22T12:32:51.056Z"
format: "markdown"
converted_by: "html-to-md-ai"
---
[]()
	
	
	
	# View source for Authentication

	
		
		← [Authentication](/Authentication)
		
		
		
		[Jump to navigation](#mw-head)
		[Jump to search](#searchInput)
		You do not have permission to edit this page, for the following reason:

The action you have requested is limited to users in the group: [Users](/index.php?title=DreamFactory_Wiki:Users&action=edit&redlink=1).---

You can view and copy the source of this page.

{{#seo:
|title=Authentication - DreamFactory Documentation
|title_mode=replace
|description=How to authenticate with DreamFactory — correct login endpoints, API keys, session tokens, and common mistakes.
|keywords=authentication, session token, JWT, API key, login, admin session, user session, system/admin/session
|og:title=Authentication
|og:type=article
|og:site_name=DreamFactory Documentation
|og:description=How to authenticate with DreamFactory — correct login endpoints, API keys, session tokens, and common mistakes.
}}
'''How to authenticate with DreamFactory — correct login endpoints, API keys, session tokens, and common mistakes.'''

&lt;span id="authentication">&lt;/span>
= Authentication =

&lt;span id="the-two-credential-system">&lt;/span>
== The Two-Credential System ==

Every DreamFactory request needs '''both''':

{| class="wikitable"
|-
! Header
! Purpose
! Where to get it
|-
| &lt;code>X-DreamFactory-API-Key&lt;/code>
| Identifies the '''app'''
| Admin UI → Apps, or via tinker
|-
| &lt;code>X-DreamFactory-Session-Token&lt;/code>
| Identifies the '''logged-in user'''
| Returned by login endpoint
|}

The API key alone is enough for some public endpoints. Most operations require both.

-----

&lt;span id="admin-login-system-administrators">&lt;/span>
== Admin Login (System Administrators) ==

&lt;pre>POST /api/v2/system/admin/session&lt;/pre>
&lt;blockquote>⚠️ '''This is the only correct endpoint for admin users.''' The following will NOT work: - &lt;code>/api/v2/admin/session&lt;/code> → returns "JWT required" error - &lt;code>/api/v2/user/session&lt;/code> → returns "missing required email" error - Any of the above without &lt;code>X-DreamFactory-API-Key&lt;/code> header
&lt;/blockquote>
'''Required headers:'''

&lt;syntaxhighlight lang="text">
Content-Type: application/json
X-DreamFactory-API-Key: &amp;lt;admin-app-api-key&amp;gt;
&lt;/syntaxhighlight>
'''Request body:'''

&lt;syntaxhighlight lang="json">{
  "email": "admin@example.com",
  "password": "yourpassword"
}&lt;/syntaxhighlight>
'''Full working example:'''

&lt;syntaxhighlight lang="bash">curl -s -X POST http://your-df-host/api/v2/system/admin/session \
  -H "Content-Type: application/json" \
  -H "X-DreamFactory-API-Key: YOUR_ADMIN_APP_API_KEY" \
  -d '{"email":"admin@example.com","password":"yourpassword"}'&lt;/syntaxhighlight>
'''Response:'''

&lt;syntaxhighlight lang="json">{
  "session_token": "eyJ0eXAiOiJKV1Qi...",
  "session_id": "eyJ0eXAiOiJKV1Qi...",
  "id": 1,
  "name": "Admin User",
  "email": "admin@example.com",
  "is_sys_admin": true,
  "last_login_date": "2026-02-18 19:45:18",
  "token_expiry_date": "2026-02-19 19:45:18"
}&lt;/syntaxhighlight>
Save the &lt;code>session_token&lt;/code> — use it as &lt;code>X-DreamFactory-Session-Token&lt;/code> in all subsequent requests.

-----

&lt;span id="regular-user-login">&lt;/span>
== Regular User Login ==

&lt;pre>POST /api/v2/user/session&lt;/pre>
Same pattern as admin login. Requires &lt;code>Content-Type: application/json&lt;/code> and &lt;code>X-DreamFactory-API-Key&lt;/code>.

&lt;syntaxhighlight lang="bash">curl -s -X POST http://your-df-host/api/v2/user/session \
  -H "Content-Type: application/json" \
  -H "X-DreamFactory-API-Key: YOUR_APP_API_KEY" \
  -d '{"email":"user@example.com","password":"yourpassword"}'&lt;/syntaxhighlight>

-----

&lt;span id="getting-the-admin-app-api-key">&lt;/span>
== Getting the Admin App API Key ==

The &lt;code>admin&lt;/code> app is created automatically on first setup. Three ways to get its key:

'''Via artisan tinker (server access):'''

&lt;syntaxhighlight lang="bash">sudo docker exec -i df-docker-web-1 php artisan tinker &lt;&lt;'EOF'
echo \DreamFactory\Core\Models\App::where('name','admin')->first()->api_key;
EOF&lt;/syntaxhighlight>
'''Via API (once you have a session):'''

&lt;syntaxhighlight lang="bash">curl -s http://your-df-host/api/v2/system/app \
  -H "X-DreamFactory-API-Key: YOUR_KEY" \
  -H "X-DreamFactory-Session-Token: YOUR_TOKEN" | python3 -m json.tool&lt;/syntaxhighlight>
'''Via Admin UI:''' Apps → admin → copy API Key field.

-----

&lt;span id="using-the-session-token">&lt;/span>
== Using the Session Token ==

Include both headers on all subsequent requests:

&lt;syntaxhighlight lang="bash">curl -s http://your-df-host/api/v2/system/service \
  -H "X-DreamFactory-API-Key: YOUR_ADMIN_APP_API_KEY" \
  -H "X-DreamFactory-Session-Token: YOUR_SESSION_TOKEN"&lt;/syntaxhighlight>
Tokens expire after '''24 hours''' by default. Re-POST to the login endpoint to refresh.

-----

&lt;span id="refresh-check-current-session">&lt;/span>
== Refresh / Check Current Session ==

&lt;syntaxhighlight lang="bash"># GET refreshes the token and returns current user info
curl -s -X GET http://your-df-host/api/v2/system/admin/session \
  -H "X-DreamFactory-API-Key: YOUR_API_KEY" \
  -H "X-DreamFactory-Session-Token: YOUR_SESSION_TOKEN"&lt;/syntaxhighlight>

-----

&lt;span id="logout">&lt;/span>
== Logout ==

&lt;syntaxhighlight lang="bash">curl -s -X DELETE http://your-df-host/api/v2/system/admin/session \
  -H "X-DreamFactory-API-Key: YOUR_API_KEY" \
  -H "X-DreamFactory-Session-Token: YOUR_SESSION_TOKEN"&lt;/syntaxhighlight>

-----

&lt;span id="common-errors-and-fixes">&lt;/span>
== Common Errors and Fixes ==

{| class="wikitable"
|-
! Error
! Cause
! Fix
|-
| &lt;code>Login request is missing required email&lt;/code>
| Wrong endpoint (&lt;code>user/session&lt;/code> for admin) or missing &lt;code>Content-Type&lt;/code> header
| Use &lt;code>POST /api/v2/system/admin/session&lt;/code> with &lt;code>Content-Type: application/json&lt;/code>
|-
| &lt;code>No session token (JWT) provided&lt;/code>
| Using &lt;code>/api/v2/admin/session&lt;/code> (wrong endpoint)
| Use &lt;code>/api/v2/system/admin/session&lt;/code>
|-
| &lt;code>No session token or API Key detected&lt;/code>
| Missing &lt;code>X-DreamFactory-API-Key&lt;/code> header
| Add the admin app's API key header
|-
| &lt;code>Invalid credentials supplied&lt;/code>
| Wrong password, or password set without DF's model (raw bcrypt won't match)
| Reset via &lt;code>php artisan tinker&lt;/code> using the DF User model — it handles hashing
|-
| &lt;code>401 Unauthorized&lt;/code>
| Expired or invalid session token
| Re-authenticate to get a new token
|}

-----

&lt;span id="quick-reference-endpoint-summary">&lt;/span>
== Quick Reference — Endpoint Summary ==

{| class="wikitable"
|-
! Action
! Method
! Endpoint
! style="text-align: center;"| Needs API Key
! style="text-align: center;"| Needs Session Token
|-
| Admin login
| POST
| &lt;code>/api/v2/system/admin/session&lt;/code>
| style="text-align: center;"| ✅
| style="text-align: center;"| ❌
|-
| User login
| POST
| &lt;code>/api/v2/user/session&lt;/code>
| style="text-align: center;"| ✅
| style="text-align: center;"| ❌
|-
| Check/refresh session
| GET
| &lt;code>/api/v2/system/admin/session&lt;/code>
| style="text-align: center;"| ✅
| style="text-align: center;"| ✅
|-
| Logout
| DELETE
| &lt;code>/api/v2/system/admin/session&lt;/code>
| style="text-align: center;"| ✅
| style="text-align: center;"| ✅
|-
| Any system operation
| *
| &lt;code>/api/v2/system/*&lt;/code>
| style="text-align: center;"| ✅
| style="text-align: center;"| ✅
|-
| Any data operation
| *
| &lt;code>/api/v2/{service}/_table/*&lt;/code>
| style="text-align: center;"| ✅
| style="text-align: center;"| ✅
|}

[[Category:Authentication]]
[[Category:Session_Token]]
[[Category:Jwt]]
[[Category:API]]

[[Category:API]]
Return to [Authentication](/Authentication).

Retrieved from "[https://wiki.dreamfactory.com/Authentication](https://wiki.dreamfactory.com/Authentication)"