Search
⌃K

Server-Side Libraries

This section explains how you can integrate Passbase into your backend and interact with our API.

General

Some clients are legally required to hold a copy of their customers' Personal data. In this case, you can retrieve any of the Data points relative to a Verification from the Passbase API:
  • The Data points required in the Verification (i.e first name, last name, document number, identity score)
  • Any metadata relative to the Verification (i.e. user agent, timestamp, user references)
We recommend you request & store as few pieces of information as possible about your users on your side. This decreases your data liability to the extent, that you only have to protect the data you truly need. If you only care that a user has been verified or is over a certain age, then you should store this as a boolean (true/false) once Passbase has completed the identity or age verification of that user.

API Key

In the previous sections, we worked with the client-side SDKs. We used the publishable API key there. Since we are now working in a server-to-server environment, you need to use the secret API key. Please never share this API key or commit it to a repo, since it gives access to your sensitive user data. If you leak this API key, a potential bad actor could retrieve and expose information about the identities of your users.
Be very careful with the secret API key. Never share it or send it through unencrypted communication methods!

Install a Server-Side Library

Follow the instructions below to install the latest Passbase server-side library in your backend project.
Javascript
Python
Java
Go
Ruby
PHP
/*
Add @passbase/node npm package to your package.json.
Passbase has no dependency but expects node version to be LTS (12.x).
*/
// Run
npm install @passbase/node --save
"""
Add Passbase's SDK package to your requirements.txt.
The SDK should work on both python 2.7 and 3+
"""
pip install passbase_sdk && pip freeze | grep passbase_sdk >> requirements.txt
// Maven users, add this dependency to your project's POM:
<dependency>
<groupId>com.passbase</groupId>
<artifactId>passbase</artifactId>
<version>0.0.1</version>
<scope>compile</scope>
</dependency>
//Gradle users, add this dependency to your project's build.gradle:
compile "com.passbase:passbase:0.0.1"
// Add Passbase to your dependencies
go get github.com/passbase/passbase-go
# Add Passbase's SDK gem to your Gemfile.
gem 'passbase', '~> 0.0.1'
//To install the bindings via Composer, add the following to `composer.json`:
{
"repositories": [
{
"type": "git",
"url": "https://github.com/passbase/passbase-php.git"
}
]
}
// Then run composer install

Usage of the Library

You can use the sample code below to initialize the server-side libraries and interact with the Passbase API. Please do not forget to use your secret API key in the header. The code below shows an example of how to request data from the Passbase API.
You can find more information about all the different functions/methods of the server-side libraries on their individual Github repository.
Javascript
Python
Java
Go
Ruby
PHP
const {
PassbaseClient,
PassbaseConfiguration,
ResponseFormats,
} = require("@passbase/node");
async function main() {
const apiKey = "YOUR_SECRET_API_KEY";
// Configure the SDK with your API Secret access key
const config = new PassbaseConfiguration({
apiKey,
format: ResponseFormats.Json,
});
const client = new PassbaseClient(config);
// Get project settings
const settings = await client.getProjectSettings();
console.log(JSON.stringify(settings, null, 4));
}
main().catch(err => {
console.error(err);
process.exit(1);
});
import passbase
from pprint import pprint
# Configure the SDK with your API Secret access key
configuration = passbase.Configuration()
configuration.api_key["X-API-KEY"] = "YOUR_SECRET_API_YEY"
api_client = passbase.ApiClient(configuration)
api_instance = passbase.ProjectApi(api_client)
try:
# Get project settings
api_response = api_instance.get_settings()
pprint(api_response)
except Exception as e:
print("Exception when calling ProjectApi->get_settings: %s\n" % e)
import com.passbase.*;
import com.passbase.api.ProjectApi;
import com.passbase.model.ProjectSettings;
import java.util.List;
import java.util.Map;
public final class App {
public static void main(String[] args) {
// Configure the SDK with your API Secret access key
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setApiKey("YOUR_SECRET_API_KEY");
ProjectApi apiInstance = new ProjectApi(defaultClient);
try {
// Get project settings
ProjectSettings settings = apiInstance.getSettings();
System.out.println(settings);
} catch (ApiException e) {
printError(e);
}
}
private static void printError(ApiException e) {
System.err.println("Exception when calling ProjectApi#getSettings");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
package main
import (
"context"
"fmt"
passbase "github.com/passbase/passbase-go"
)
func main() {
// Configure the SDK with your API Secret access key
client := passbase.NewAPIClient(passbase.NewConfiguration())
ctx := context.WithValue(context.Background(), passbase.ContextAPIKey, passbase.APIKey{
Key: "YOUR_SECRET_API_KEY",
})
// Get project settings
settings, _, err := client.ProjectApi.GetSettings(ctx)
if err != nil {
panic(err)
}
fmt.Println("Setting for ", settings.Slug, "->", settings)
}
require 'passbase'
# Setup authorization
Passbase.configure do |config|
# Configure API key authorization: SecretApiKey
config.api_key['SecretApiKey'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['SecretApiKey'] = 'Bearer'
end
api_instance = Passbase::ProjectApi.new
begin
# Get project settings
result = api_instance.get_settings
p result
rescue Passbase::ApiError => e
puts "Exception when calling ProjectApi->get_settings: #{e}"
end
<?php
use App\Http\Controllers\Controller;
use Passbase\Configuration;
use Passbase\api\IdentityApi;
use GuzzleHttp\Client;
class APIController extends Controller
{
public function api_call()
{
// Configure the SDK with your API Secret access key
$config = Configuration::getDefaultConfiguration()->setApiKey('X-API-KEY', 'SECRET-KEY');
$apiInstance = new IdentityApi(
new Client(),
$config
);
// Unique identity access key received from webhooks
$id= "identityAccessKey";
try {
$result = $apiInstance->getIdentityById($id);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling IdentityApi->getIdentityById: ', $e->getMessage(), PHP_EOL;
}
}
}
?>