Skip to content

Recognizing Users ‚Äč

Signing in is one of the most basic uses of a pass request. In this example, we'll demonstrate a pass request that allows an app to request some basic user info.

Let's define a request topic called org.passes.example.request-user-profile with the type:

typescript
// The profile info fields that can be requested
type ProfileInfoType = 'email' | 'profile.name' | 'profile.picture';

// Array of requested profile info fields
type UserProfileRequest = ProfileInfoType[];
// Record from permission type to value
type UserProfileResult = Record<ProfileInfoType, string>;

const requestUserProfile = new RequestTopic<UserProfileRequest, UserProfileResult>({
  id: 'org.passes.example.request-user-profile',
  requestBodyCodec: Codecs.Json,
  resultBodyCodec: Codecs.Json,
});

const result = await requestUserProfile.sendRequest([
  'email',
  'profile.name',
  'profile.picture',
]);

if (result.status === 'accepted') {
  const userProfileInfo = result.body;
}
Interactive Example
This demo requests basic user profile info.
Click "Send Request"
The Pass Request will appear here