---
title: "Custom Implementation"
canonical: "https://docs.pbs.org/space/MV/5799991/Custom+Implementation"
format: markdown
---
> Macro (toc)

## Overview

This document is for station developers who want to implement a custom solution for Passport on their station site.

There are two ways your users can go through the activation process:

1. Require a manual activation by the user (i.e.: the user must type an activation code into the site.)
2. Activate the user automatically in the background (i.e.: programmatically activate the user so they can just go to your site and already be activated with no action required.)

[**Take a deep dive into how activation works**](https://docs.pbs.org/space/MV/5799973/Technical+Deep+Dive%3A+how+'activation'+works)

## Process

### Sign up

- set up a [PBS Account.](https://pbs-docs.atlassian.net/wiki/spaces/uua/pages/5177374)
- [submit a help desk ticket](http://digitalsupport.pbs.org/support/tickets/new) requesting [OAUTH2 client credentials](https://pbs-docs.atlassian.net/wiki/spaces/uua/pages/5177374). Please provide the following:
  - Any redirect URI(s) you may have.
  - Your station name as it should be referred to in the API (example: KOCE).
- [Create MVault membership](https://docs.pbs.org/space/MV/5799938/Membership+Vault+(Passport)+Developer+Documentation) (sync with station crm)

### Activate

> ⚠️ **This part can be manual or programmatically handled in the background - both require **[**PBS account**](https://pbs-docs.atlassian.net/wiki/spaces/uua/pages/5177374)**.**

- Send member their membership token via email or web or snail mail. Member goes to your site to activate using token.
- Use the PATCH endpoint to update member information ([learn more about the PATCH endpoint](https://docs.pbs.org/space/MV/5799969/Membership+Vault+API#Update--the-membership-ID-for-a--Membership-(PATCH))). Member goes to your site and logs in to find they are already activated.

### Consume content

- Display Passport content.

## Custom implementation

### Create custom PBS Account sign-in links

- Provide a login link that is unique to your station site. Example: [www.wgbh.org/login](http://www.wgbh.org/login)
- After a user donates, and an MVault membership record is created.
- Your station CRM should save the MVault membership UID in the session, then present a custom PBS Account Sign In / Link page using the following code:

##### **Custom sign in links - Sign in with Google**

```
https://account.pbs.org/oauth2/social/login/google-oauth2/?scope={scope type}+{station name as specified in OAUTH2}&client_id={your client_id}&redirect_uri={redirect URI as specified in OAUTH2}&response_type=code
```

Example: https://account.pbs.org/oauth2/social/login/google-oauth2/?scope=account+wpbs&client_id=TjsKCm3VA92wtsDymz1iDtFiCTpV83fBM&redirect_uri=http://www.wpbs.org/passport/passport.cfm&response_type=code


##### **Custom sign in links - Sign in with Facebook**

```
https://account.pbs.org/oauth2/social/login/facebook/?scope={scope type}+{station name as specified in OAUTH2}&client_id={your client_id}&redirect_uri={redirect URI as specified in OAUTH2}&response_type=code
```

Example: https://account.pbs.org/oauth2/social/login/facebook/?scope=account+wpbs&client_id=TjsKCm3VA92wtsDymz1iDtFiCTpV83fBM&redirect_uri=http://www.wpbs.org/passport/passport.cfm&response_type=code


##### **Custom sign in links - Sign in with PBS Account**

```
https://account.pbs.org/oauth2/authorize/?scope={scope type}+{station name as specified in OAUTH2}&client_id={your client_id}&redirect_uri={redirect URI as specified in OAUTH2}&response_type=code
```

Example: https://account.pbs.org/oauth2/authorize/?scope=account+wpbs&client_id=TjsKCm3VA92wtsDymz1iDtFiCTpV83fBM&redirect_uri=http://www.wpbs.org/passport/passport.cfm&response_type=code


##### **Sample response**

```
http://www.wpbs.org/passport/passport.cfm?scope=account+wpbs&code=ahCqWWyH9ozeJqX8hZSbSaJhmO2kty#_=_ 
```

### Retrieve OAuth token

The following code should be exchanged on the server side for an OAuth token:

```
https://account.pbs.org/oauth2/token?client_id={your client_id}&client_secret={your client_secret}&redirect_uri=http://video.pbs.org/login/callback&code={pids-auth-code}
```

##### **Sample token exchange response**

```
Example Token Exchange response:
{
  "access_token": "{access-token}", 
  "token_type": "Bearer", 
  "expires_in": {seconds-til-expiration}, 
  "refresh_token": "{refresh-token}", 
  "scope": "account wgbh"
} 
```

The token that is returned can be used to retrieve user information, including the user's PID, by calling the URL and passing in the access token as the Authorization header:

```
GET https://account.pbs.org/oauth2/user/info/ HTTP/1.1
Authorization: {access_token}
```

##### **Sample user information response**

```
{
    "id": {id},
    "email": {email},
    "first name": {First-name},
    "last name": {last-name},
    "zip code": {zip-code}
} 
```

### Activate the MVault membership

Now the MVault user can be "Activated" by doing a PATCH request to link the PBS Account PID to the MVault member record:

```
PATCH /api/f3842586-2c40-43fa-a79f-841fd5f2b9cb/memberships/{mvault-membership-uid-saved-in-session}/
Content-Type: application/json 

{
    "uid": "{id-from-pbs-account-user-info-response}"
}
```


## FAQ

- **What does a PID do?**  
The PID determines if the user has access to MVOD content. It also gets them personalized features in the video player. Profile Service (via the PID) keeps track of how much of a full-length episode I've watched. The partner player will bring me back to that point in the video if I close the browser, reopen it, and try watching the video again.
- **If a user has logged in to PBS using the Oauth2 mechanisms (google,fb,direct) do I still need to pass the PID into the partner player?**  
Yes. A partner player URL with PID may look like the following: [http://player.pbs.org/widget/partnerplayer/2365722380](http://player.pbs.org/widget/partnerplayer/2365722380/?uid=abc123)[/?uid=abc123](http://player.pbs.org/widget/partnerplayer/2365722380/?uid=abc123)  
[ ](http://player.pbs.org/widget/partnerplayer/2365722380/?uid=abc123)
- **Is there a way to log a user off of PBS and forward them to a URL target page?**  
No.