---
title: "Login Bypass"
canonical: "https://docs.pbs.org/space/DLM/3577964/Login+Bypass"
format: markdown
---
> ⚠️ **<span style="color: #ff0000">Are you using the PBS LearningMedia Admin tool? </span>**[<u>**<span style="color: #ff0000">Click here for the PBS LearningMedia user manual</span>**</u>](https://docs.pbs.org/x/KArKAQ)

> Macro (toc)

## Workflow

The way the system interacts is presented in this sequence diagram:

> Macro (gliffy)

## Methods

The login bypass API consists of only two methods: create_token and login.

| **Description** | **When** | **Then** |
| --- | --- | --- |
| New external user | Create token and save external user in LM db<br>- Method: POST
- URL: [http://www.pbslearningmedia.org/bypass/create_token/](http://www.pbslearningmedia.org/bypass/create_token/)<br>Params:<br>- key (required) - 3rd party consumer key
- user_id (required) - external user id
- email (required) - user email
- lm_url (required) - LM resource URL (use relative path)
- first_name - user first name
- last_name - user last name
- username - desired username in LM db
- postal_code - U.S. Zip Code for Localization | On success, the token is returned with the redirect_url (HTTP code 200):<br>```
{
    "status":"success",
    "redirect_url":"http://www.pbslearningmedia.org/bypass/login/6946800f-fd23-4d7a-952c-7bafd474c2bc/?next=%2Fresource%2F51b8859a-8712-435f-92b3-d90283204a73%2Fseparation-of-powers%2F"
}
```<br>If the key is not valid HTTP code 401 is returned.<br>In case of validation error a different response is received (HTTP code 400):<br>```
{
    "status":"error",
    "message":"Validation error.",
    "user_id":["This field is required."],
    "email":["This field is required."]
}
``` |
| New external user, but the email already exists in LM database for a user | (same as above) | Response contains a redirect_url to UUA login (HTTP code 200):<br>```
{
    "status":"success",
    "redirect_url":"http://www.pbslearningmedia.org/uua/login/?next=/resource/51b8859a-8712-435f-92b3-d90283204a73/separation-of-powers/"
}
``` |
| New external user, email does not exist in LM database, but the suggested username is taken | (same as above) | Response contains the validation error (HTTP code 400):<br>```
{
    "status":"error",
    "message":"Validation error.",
    "username":["This username is already taken."]
}
``` |
| Login based on token | Login user based on token:<br>- Method: GE
- URL: [http://www.pbslearningmedia.org/bypass/login/<token>/](#)  
  
Params:
- next (required) - the URL to follow | If login is successful (token is found and is created less than 10 seconds ago) a 302 HTTP code is returned with next param set as next location.<br>If not, 403 is returned.<br>If next parameter is not provided, then 404 is returned. |

## CURL Example

The following is an example of interacting with the API using curl, a command line tool.  For more information on how the POST data is submitted via curl, see [http://curl.haxx.se/docs/manpage.html](http://curl.haxx.se/docs/manpage.html).

```
$ curl --verbose \
--data-urlencode "key=<your-login-bypass-key>" \
--data-urlencode "lm_url=/" \
--data-urlencode "user_id=dvh-140819" \
--data-urlencode "email=dvh-140819@example.com" \
--data-urlencode "first_name=Example" \
--data-urlencode "last_name=User" \
http://www.pbslearningmedia.org/bypass/create_token/

* Hostname was NOT found in DNS cache
*   Trying 54.243.104.235...
* Connected to www.pbslearningmedia.org (54.243.104.235) port 80 (#0)
> POST /bypass/create_token/ HTTP/1.1
> User-Agent: curl/7.35.0
> Host: www.pbslearningmedia.org
> Accept: */*
> Content-Length: 135
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 135 out of 135 bytes
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Tue, 19 Aug 2014 15:27:44 GMT
* Server Apache is not blacklisted
< Server: Apache
< Set-Cookie: www.apache.sid=10.31.168.131.1408462064038563; path=/; domain=.pbslearningmedia.org
< Vary: Cookie,Accept-Encoding
< X-PBS-appsvrip: 10.41.148.187
< X-PBS-appsvrname: panda-prod-app #98
< transfer-encoding: chunked
< Connection: keep-alive
< 
* Connection #0 to host www.pbslearningmedia.org left intact
{"status": "success", "redirect_url": http://www.pbslearningmedia.org/bypass/login/xxx/?next=%2F}
```