Client Libraries

PHP

Download onetime-api.php
by Christopher Murtagh (added 2011-12-21)

Usage Example

<?php
  include('onetime-api.php');
  $myOnetime = new OneTimeSecret;
  $myOnetime->setCustomerID('YOUR_EMAIL');
  $myOnetime->setToken('YOUR_OTS_APIKEY');
  $myOnetime->setRecipient('foo@openbridge.com');
  $myOnetime->setTTL(7200);
  $myResult = $myOnetime->shareSecret('Jazz, jazz and more jazz.', 'thepassword');
  print $myOnetime->getSecretURI($myResult);
?>
      

Ruby

Download onetime-api.rb
by Delano (added 2011-12-21)

Usage Example

require 'onetime/api'
api = Onetime::API.new 'YOUR_EMAIL', 'YOUR_OTS_APIKEY'
options = {
  :secret => 'Jazz, jazz and more jazz.',
  :recipient => 'foo@openbridge.com',
  :ttl => 7200
}
ret = api.post '/share', options
puts ret['secret_key']
      

Python

Download onetimesecret.py
by Vladislav Stepanov (added 2012-06-26)

Usage Example

from onetimesecret import OneTimeSecret

o = OneTimeSecret("YOUR_EMAIL", "YOUR_OTS_APIKEY")
secret = o.share(u"test")

print o.retrieve_secret(secret["secret_key"])
# {u'secret_key': u'dtr7ixukiolpx1i4i87kahmhyoy2q65',
# u'value': u'test'}
      

Perl

Download Net::OneTimeSecret
by Kyle Dawkins (added 2012-01-06)

Usage Example

#!/usr/bin/env perl

use Net::OneTimeSecret;

# Note: replace these with yours in order for this to work!
my $customerId  = 'YOUR_EMAIL';
my $testApiKey  = 'YOUR_OTS_APIKEY';

my $api = Net::OneTimeSecret->new( $customerId, $testApiKey );
my $result = $api->shareSecret( 'Jazz, jazz and more jazz.',
                   passphrase => 'thepassword',
                   recipient => 'kyle@shoffle.com',
                   ttl => 7200,
                 );
printf( "%s\n", $result->{secret_key} );

my $secret = $api->retrieveSecret( $result->{secret_key}, passphrase => "thepassword" );
printf( "%s\n", $secret->{value} );
      

Java

Download onetime-java
by Marcin Pawlowski (added 2014-05-22)

Usage Example

OneTimeSecret ots = new OneTimeSecretRestImpl(
    "https://path/to/ots/instance",
    "ots-username",
    "ots-apikey");

GenerateResponse generateResponse = ots.generate(
                new GenerateRequest.Builder()
                        .withPassphrase("supersecret")
                        .build());

RetrieveResponse retrieveResponse = ots.retrieve(
                new RetrieveRequest.Builder()
                        .withSecretKey(shareResponse.getSecretKey())
                        .withPassphrase("supersecret")
                        .build());

assertEquals(generateResponse.getValue(), retrieveResponse.getValue());
      

C#

Download OneTimeSharp
by Vladislav Stepanov (added 2014-05-29)

Usage Example

# You can use OneTimeSharp in any of your projects which are compatible with .NET (4.0+) or Mono (2.10.8+).
using VStepanov.OneTimeSharp;

class Test
{
    static void Main(string[] args)
    {
        var ots = new OneTimeSecret("YOUR_EMAIL", "YOUR_OTS_APIKEY");

        var generated = ots.GenerateSecret();

        Console.WriteLine(generated.Value); // LR*?us*A(UT*

        Console.WriteLine(generated.SecretKey); // ikzx3m77j5by8411cg5lk5fvfylvl0i
        Console.WriteLine(ots.GetSecretLink(generated)); // https://secret.openbridge.io/secret/ikzx3m77j5by8411cg5lk5fvfylvl0i

        var shared = ots.ShareSecret("Hello, OTS!");

        Console.WriteLine(shared.MetadataKey); // kd6rgsucl98qbgu9eavjq4k5sdxsom0
        Console.WriteLine(ots.GetMetadataLink(shared)); // https://secret.openbridge.io/private/kd6rgsucl98qbgu9eavjq4k5sdxsom0
    }
}