Basic Auth
From DreamFactory
Toddappleton (Talk | contribs) |
Toddappleton (Talk | contribs) |
||
Line 1: | Line 1: | ||
− | DreamFactory | + | DreamFactory supports Basic HTTP Authentication both via Authorization request header and URL. |
=== API Endpoints === | === API Endpoints === | ||
Line 51: | Line 51: | ||
<pre> | <pre> | ||
− | curl http://jdoe%40dreamfactory.com:secret@foo.com/ | + | curl http://jdoe%40dreamfactory.com:secret@foo.com/api/v2/user |
</pre> | </pre> | ||
'''''Note:''' %40 = url_encode(@)'' | '''''Note:''' %40 = url_encode(@)'' | ||
Line 57: | Line 57: | ||
* Username: jdoe@dreamfactory.com | * Username: jdoe@dreamfactory.com | ||
* Password: secret | * Password: secret | ||
− | * Service | + | * Service: user |
− | + |
Revision as of 18:51, 30 June 2016
DreamFactory supports Basic HTTP Authentication both via Authorization request header and URL.
Contents
API Endpoints
Using Authorization request header
{METHOD} https://{url}/api/v2/{service}/{resource}
Request Header:
Accept:application/json Accept-Encoding:gzip, deflate, sdch Accept-Language:en-US,en;q=0.8 Authorization:Basic {base64_encode(username + : + password)} <-- Basic Authentication Connection:keep-alive Content-Type:application/json ....
Using URL
{METHOD} https://username:password@{url}/api/v2/{service}/{resource}
Note: Basic Authentication over URL will not work for user agents that support request header (most web browsers)
Example - Basic Authentication via Authorization request header using JQuery Ajax call
var username = $('#username').val(); var password = $('#password').val(); var url = $('#url').val(); $.ajax({ url: url, async: true, type:'GET', dataType: 'json', contentType: 'application/json', beforeSend: function(xhr) { xhr.setRequestHeader("Authorization", "Basic "+btoa(username+':'+password)); }, success: function(json){ ... }, error: function(err) { ... } });
Example - Basic Authentication via URL using CURL
curl http://jdoe%40dreamfactory.com:secret@foo.com/api/v2/user
Note: %40 = url_encode(@)
- Username: jdoe@dreamfactory.com
- Password: secret
- Service: user