Skip to content
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

55 lines (47 sloc) 1.88 KB
using System;
using System.IO;
using Tokenio.Proto.Common.AliasProtos;
using Tokenio.Security;
using TppMember = Tokenio.Tpp.Member;
namespace Tokenio.Sample.Tpp
public static class CreateMemberSample
/// <summary>
/// Creates and returns a new token member.
/// </summary>
/// <returns>a new Member instance</returns>
public static TppMember CreateMember()
// Create the client, which communicates with
// the Token cloud.
var key = Directory.CreateDirectory("./keys");
Tokenio.Tpp.TokenClient tokenClient = Tokenio.Tpp.TokenClient.NewBuilder()
.WithKeyStore(new UnsecuredFileSystemKeyStore(key.FullName))
// An alias is a "human-readable" reference to a member.
// Here, we use a random email. This works in test environments.
// but in production, TokenOS would try to verify we own the address,
// so a random address wouldn't be useful for much.
// We use a random address because otherwise, if we ran a second
// time, Token would say the alias was already taken.
Alias alias = new Alias
Value = TestUtil.RandomNumeric(10) + "",
Type = Alias.Types.Type.Email
TppMember newMember = tokenClient.CreateMemberBlocking(alias);
// let user recover member by verifying email if they lose keys
return newMember;
catch (IOException ioe)
throw new ArgumentException("", ioe);
You can’t perform that action at this time.