Basic Auth

From DreamFactory
Jump to: navigation, search
(Created page with "Ambulance Officer Amado Cherrington from Sardis, has several pursuits including backgammon, Web Hosting and car. Intends to quit work and take the family to lots of the notewo...")
 
(Created page with "### Tutorial DreamFactory 2.0 supports Basic HTTP Authentication both via Authorization request header and URL. ### API Endpoints #### Using Authorization request header <...")
Line 1: Line 1:
Ambulance Officer Amado Cherrington from Sardis, has several pursuits including backgammon, Web Hosting and car. Intends to quit work and take the family to lots of the noteworthy heritage listed locales on the globe such as Lalibela.<br><br>my blog: web hosting sites; [https://s3-eu-west-1.amazonaws.com/webhosting123/index.html recommended],
+
### Tutorial
 +
 
 +
DreamFactory 2.0 supports Basic HTTP Authentication both via Authorization request header and URL.
 +
 
 +
### API Endpoints
 +
 
 +
#### Using Authorization request header
 +
 
 +
<pre>{METHOD} https://{url}/api/v2/{service}/{resource}</pre>
 +
Request Header:
 +
<pre>
 +
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
 +
  ....
 +
</pre>
 +
 
 +
#### Using URL
 +
 
 +
<pre>{METHOD} https://username:password@{url}/api/v2/{service}/{resource}</pre>
 +
 
 +
> _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
 +
 
 +
<source lang="JavaScript">
 +
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) {
 +
        ...
 +
    }
 +
});
 +
</source>
 +
 
 +
### Example - Basic Authentication via URL using CURL
 +
 
 +
<pre>
 +
curl http://username:password@foo.com/rest/system/service
 +
</pre>

Revision as of 21:19, 14 October 2015

      1. Tutorial

DreamFactory 2.0 supports Basic HTTP Authentication both via Authorization request header and URL.

      1. API Endpoints
        1. 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
 ....
        1. 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)_

      1. 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) {
        ...
    }
});
      1. Example - Basic Authentication via URL using CURL
curl http://username:password@foo.com/rest/system/service