Project

General

Profile

Overview

The OAuth plugin is a webclient plugin for using OAuth authentication.
It is based on the scribe-java lib https://github.com/fernandezpablo85/scribe-java .
Currently, it can be used for Facebook, Linkedin, Xero(public and private applications) authentication.
It can be extended to support more OAuth apis in the future.

Facebook sample:
var client_id = "your_api_secret";
var secret_key = "your_app_id";
var resource_url = "https://graph.facebook.com/me";
var oauth_api = plugins.oauth.OAuthAPI.FACEBOOK;
var scope = null;
var authReq = plugins.oauth.createOAuthRequest(oauth_api, client_id, secret_key, scope, oAuthLoginCallback);
authReq.setResourceUrl(resource_url);
authReq.execute();
function oAuthLoginCallback(verified, authenticateResult) {
if (verified) var email = authenticateResult.getAttributeValue('email');
}

Xero sample:
Get resource example:
var oauth_api = plugins.oauth.OAuthAPI.XERO;
var client_id = "your consumer id";
var secret = "your RSA private key in PKCS8 format";
var resource_url = "https://api.xero.com/api.xro/2.0/Organisation";
var method = plugins.oauth.Methods.GET;
var request = plugins.oauth.createOAuthRequest(oauth_api, client_id, secret, method);
request.setHeader("Accept","application/json");
request.setResourceUrl(resource_url);
request.execute();
/**@type{plugins.oauth.JSOAuthResponseJSON}*/
var response = request.getResponse();
response.getAttributeValue("Organisations");

Create new resource example:
var oauth_api = plugins.oauth.OAuthAPI.XERO;
var client_id = "your consumer id";
var secret = "your RSA private key in PKCS8 format";
var resource_url = "https://api.xero.com/api.xro/2.0/Items";
var method = plugins.oauth.Methods.PUT;
var content = "<Items><Item><Code>Item-123</Code></Item></Items>";
var request = plugins.oauth.createOAuthRequest(oauth_api, client_id, secret, method);
request.setPostData("xml",content);
request.setResourceUrl(resource_url);
request.execute();
var response = request.getResponse();

Get resource as pdf (byte array):
var oauth_api = plugins.oauth.OAuthAPI.XERO;
var client_id = "your client id";
var secret = "your RSA private key in PKCS8 format";
var method = plugins.oauth.Methods.GET;
var request = plugins.oauth.createOAuthRequest(oauth_api, client_id, secret, method);
request.setResourceUrl("https://api.xero.com/api.xro/2.0/Invoices/INV-0027");
request.setHeader("Accept","application/pdf");
request.execute();
var pdf_content = request.getResponse().getContent();

  • License: Apache License, Version 2.0
  • Category: Plugin

Issue tracking

open closed Total
Defect 1 0 1
Feature 5 3 8
Patch 0 0 0

View all issues | Summary

Members

Project Leader: Edit Mera