When calling REST Services using the JavaScript API rather than by using a Rest Resource, you need to handle authentication using code.
The HttpAuthentication API contains the following methods:
- createBasicAuthentication(username, password)
- createDigestAuthentication(username,password)
- createNTLMAuthentication(username, password, workstation, domain)
- createOAuthAuthentication(name, scope, username, password,additional parameters) – creates an OAuthAuthentication object using the named OAuth Configuration in the server admin app. This OAuth Configuration must already be authorized using services.oauth.authorise()
The Authentication Object returned by one of the HttpAuthentication methods will need to be passed as a parameter into your JavaScript REST Calls.
e.g.
services.security.oauth.authorise('Github');
var auth = HttpAuthentication.createOAuthAuthentication('Github');
var uri = 'https://github.com/login/oauth/access_token';
services.rest.get(uri, null, null, authentication);