generateODataHttpClient() method

Generates an OData client that uses the AuthProxy plugin to make requests.

This is useful if you are using Datajs, but want to make use of the certificate features of AuthProxy. Datajs is a javascript library useful for accessing OData services. Datajs has a concept of an HttpClient, which does the work of making the request. This function generates an HttpClient that you can specify to Datajs so you can provide client certificates for requests. If you want to use the generated HTTP client for all future Datajs requests, you can do that by setting the OData.defaultHttpClient property to the return value of this function. Once that is done, then doing OData stuff with Datajs is almost exactly the same, but you can add a certificateSource to a request.

Syntax

generateODataHttpClient()

Example

OData.defaultHttpClient = sap.AuthProxy.generateODataHttpClient();

// Using a certificate from file, for example.
fileCert = new sap.AuthProxy.CertificateFromFile("mnt/sdcard/cert.p12", "password", "certKey");

// This is the same request object you would have created if you were just using Datajs, but now
// you can add the extra 'certificateSource' property.
var createRequest = {
    requestUri: "http://www.example.com/stuff/etc/example.svc",
    certificateSource : fileCert,
    user : "username",
    password : "password",
    method : "POST",
    data:
    {
         Description: "Created Record",
         CategoryName: "Created Category"
    }
}

// Use Datajs to send the request.
OData.request( createRequest, successCallback, failureCallback );

Source

authproxy.js, line 734.