JavaScript

This tutorial will walk you through how to use the callbacks in the JavaScript SDK. It is expected that you have already read Getting Started.

Authentication

To use server hosted authentication, just pass the google id token into the Pathfinder constructor.

var pf = new Pathfinder(MY_APP_ID, ID_TOKEN);

To use your own authentication, you have two options. Option 1 is to specify the authentication server url as a constructor argument.

var pf = new Pathfinder(MY_APP_ID, AUTH_INFO, "my_auth_server_url");

This causes the Pathfinder object to send a get request to my_auth_server_url, passing along AUTH_INFO, and the connection id as query parameters:

GET HTTPS://my_auth_server.com?user_id=AUTH_INFO&connection_id=CONNECTION_ID&application_id=APP_ID

AUTH_INFO can be any kind of string that you can use to identify or authenticate the user with.

Overriding the authenticate function in Pathfinder

Another way to implement custom authentication besides using constructor arguments is to assign your own authenticate function.

Pathfinder.prototype.authenticate = function(connection_id, next){
  // do something with connection id to prepare your authentication server
  next();
};

var pf = new Pathfinder(APP_ID);

When you replace the authenticate function, you only need to provide the application id into the constructor argument.