Skip to content

Instantly share code, notes, and snippets.

View FlorianWendel's full-sized avatar

Florian Wendel FlorianWendel

  • Mannheim, Germany
View GitHub Profile
@FlorianWendel
FlorianWendel / server
Created March 27, 2017 08:00
Pseudocode for OAuth with CloudRail on a webserver
function startFacebookAuthentication(request, response) {
function redirectReceiver(url) {
response.redirect(url);
return null;
}
Profile service = new Facebook(
redirectReceiver,
"[clientId]",
// Initialize like usual
CRCloudRail.setAppKey("[CloudRail key]")
let dropbox = Dropbox.init(clientId: "[clientId]", clientSecret: "[clientSecret]")
// Specify the URL of the Dropbox API endpoint, the base URL is prepended by default
let req = CRAdvancedRequestSpecification.init(url: "/sharing/list_folders")
// Set the HTTP request method to POST
req.method = "POST"
// Initialize like usual
[CRCloudRail setAppKey:@"[CloudRail key]"];
CRDropbox * dropbox = [[CRDropbox alloc] initWithClientId:@"[clientId]" clientSecret:@"[clientSecret]";
// Specify the URL of the Dropbox API endpoint, the base URL is prepended by default
CRAdvancedRequestSpecification * req = [[CRAdvancedRequestSpecification alloc] initWithUrl:@"/sharing/list_folders"];
// Set the HTTP request method to POST
req.method = @"POST";
// Initialize like usual
Settings.setKey([CloudRail key]);
const dropbox = new Dropbox([Credentials etc.]);
// Specify the URL of the Dropbox API endpoint, the base URL is prepended by default
let req = new AdvancedRequestSpecification("/sharing/list_folders");
// Set the HTTP request method to POST
req.setMethod("POST");
// Initialize like usual
CloudRail.setAppKey([CloudRail key]);
Dropbox dropbox = new Dropbox([Credentials etc.]);
// Specify the URL of the Dropbox API endpoint, the base URL is prepended by default
AdvancedRequestSpecification req = new AdvancedRequestSpecification("/sharing/list_folders");
// Set the HTTP request method to POST
req.setMethod("POST");
// Initialize like usual
CloudRail.setAppKey([CloudRail key]);
Dropbox dropbox = new Dropbox([Credentials etc.]);
// Specify the URL of the Dropbox API endpoint, the base URL is prepended by default
AdvancedRequestSpecification req = new AdvancedRequestSpecification("/sharing/list_folders");
// Set the HTTP request method to POST
req.setMethod("POST");

How to test CloudRail on Heroku Alpha

Overview

If you are already using Heroku you can start with step 5.

  1. Create a Heroku account.
  2. Add credit card information to verify the account. No charge will occur due to this test.
  3. Install the Heroku CLI and login.
  4. Create a new Heroku application. It does not need to have code or run in a dyno.
CloudRail.setAppKey("[CloudRail License Key]");
// CloudStorage cs = new Box(context, "[clientIdentifier]", "[clientSecret]");
// CloudStorage cs = new GoogleDrive(context, "[clientIdentifier]", "[clientSecret]");
// CloudStorage cs = new Dropbox(context, "[clientIdentifier]", "[clientSecret]");
CloudStorage cs = new OneDrive(context, "[clientIdentifier]", "[clientSecret]");
new Thread() {
@Override
public void run() {