Create a new user

Create a new user on the Pocket Gateway

2 minute read

Create a new user

First, you will need to create a new user and an accompanying account.

Replace the environment variables with your given and family name, email, and temporary password.

You will be asked to change the password once the user identifies themselves.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
export \
	USER_GIVEN_NAME="sarah" \
	USER_FAMILY_NAME="kerrigan" \
 	USER_EMAIL="sarah.kerrigan@char.com" \
 	USER_PASSWORD="zeratul"

curl \
  --request POST \
  --url "https://alpha.api.pocket-portfolio.com/objects/user" \
  --header "Content-Type: application/json" \
  --data '{
  	"given_name": "${USER_GIVEN_NAME}",
    "family_name": "${USER_FAMILY_NAME}",
    "email": "${USER_EMAIL}",
    "password": "${USER_PASSWORD}",
    "tier": "free"
  }'

If your user was created successfully, you should see:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
{
	"created_at": "2021-02-06T16:52:14.129Z",
	"email": "sarah.kerrigan@char.com",
	"given_name": "sarah",
	"user_id": "Y60107f369dbd1a0068f0232z",
	"family_name": "kerrigan",
	"picture": "https://s.gravatar.com/.../avatars%2Fpe.png",
	"user_metadata": {
		"tier": "tier-0",
		"verified": false
	}
}

export USER_USER_ID="Y60107f369dbd1a0068f0232z"
1
"Bad Request - Received a bad request from the user"

Generate an access token

We’re now going to generate a JWT to authenticate with the Pocket Gateway.

1
2
3
4
5
curl \
  --request POST \
  --url "https://alpha.api.pocket-portfolio.com/object/token/password" \
  --header "Content-Type: application/json" \
  --data '{"user_id": ${USER_USER_ID}, "password": "${USER_PASSWORD}"}'

You should get a response containing the token in the access_token attribute.

1
2
3
4
5
6
7
{
	"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ildfd...",
	"expires_in": 43200,
	"token_type": "Bearer",
}

export ACCESS_TOKEN="eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ildfd..."
1
"Bad Request - Received a bad request from the user"

👍 Wonderful! You’ve created a new user on the Pocket Cloud and now have an access token to start deploying resources!

Last modified April 3, 2023: fix ubuntu issues (dc29291)