{
	"info": {
		"_postman_id": "679e01ea-9776-4e3c-9307-a37d8ff962af",
		"name": "API Authorization Lab",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"item": [
		{
			"name": "Scopes",
			"item": [
				{
					"name": "4. Create Api Auth Server Scope - deleteTodo",
					"event": [
						{
							"listen": "test",
							"script": {
								"id": "12903c25-6e14-43a4-bcd9-263eae6f8625",
								"exec": [
									"var jsonData = JSON.parse(responseBody);",
									"postman.setEnvironmentVariable(\"oidc_client_scope_delete\", jsonData.id);"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"auth": {
							"type": "bearer",
							"bearer": [
								{
									"key": "token",
									"value": "{{access_token}}",
									"type": "string"
								}
							]
						},
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"type": "text",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n\t\"value\": \"deleteTodo\",\n\t\"description\": \"deleteTodo permission to permit deletion of existing To-Do Lists\"\n}\n\n"
						},
						"url": {
							"raw": "https://api.{{us_or_eu}}.onelogin.com/api/2/api_authorizations/{{api_auth_id}}/scopes",
							"protocol": "https",
							"host": [
								"api",
								"{{us_or_eu}}",
								"onelogin",
								"com"
							],
							"path": [
								"api",
								"2",
								"api_authorizations",
								"{{api_auth_id}}",
								"scopes"
							]
						}
					},
					"response": []
				},
				{
					"name": "5. Create Api Auth Server Scope - createTodo",
					"event": [
						{
							"listen": "test",
							"script": {
								"id": "93802c9a-4269-4cb6-8f4d-f550843e66b7",
								"exec": [
									"var jsonData = JSON.parse(responseBody);",
									"postman.setEnvironmentVariable(\"oidc_client_scope_create\", jsonData.id);"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"auth": {
							"type": "bearer",
							"bearer": [
								{
									"key": "token",
									"value": "{{access_token}}",
									"type": "string"
								}
							]
						},
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"type": "text",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n\t\"value\": \"createTodo\",\n\t\"description\": \"createTodo permission to permit creation of a To-Do List\"\n}\n\n"
						},
						"url": {
							"raw": "https://api.{{us_or_eu}}.onelogin.com/api/2/api_authorizations/{{api_auth_id}}/scopes",
							"protocol": "https",
							"host": [
								"api",
								"{{us_or_eu}}",
								"onelogin",
								"com"
							],
							"path": [
								"api",
								"2",
								"api_authorizations",
								"{{api_auth_id}}",
								"scopes"
							]
						}
					},
					"response": []
				},
				{
					"name": "6. Get Api Auth Server Scopes",
					"request": {
						"auth": {
							"type": "bearer",
							"bearer": [
								{
									"key": "token",
									"value": "{{access_token}}",
									"type": "string"
								}
							]
						},
						"method": "GET",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json",
								"type": "text"
							}
						],
						"body": {
							"mode": "raw",
							"raw": ""
						},
						"url": {
							"raw": "https://api.{{us_or_eu}}.onelogin.com/api/2/api_authorizations/{{api_auth_id}}/scopes",
							"protocol": "https",
							"host": [
								"api",
								"{{us_or_eu}}",
								"onelogin",
								"com"
							],
							"path": [
								"api",
								"2",
								"api_authorizations",
								"{{api_auth_id}}",
								"scopes"
							]
						}
					},
					"response": []
				}
			]
		},
		{
			"name": "Client Apps",
			"item": [
				{
					"name": "7. Add Api Auth Server Client",
					"request": {
						"auth": {
							"type": "bearer",
							"bearer": [
								{
									"key": "token",
									"value": "{{access_token}}",
									"type": "string"
								}
							]
						},
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json",
								"type": "text"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n\t\"app_id\": {{oidc_client_app_id}},\n\t\"scopes\": [{{oidc_client_scope_create}}]\n}"
						},
						"url": {
							"raw": "https://api.{{us_or_eu}}.onelogin.com/api/2/api_authorizations/{{api_auth_id}}/clients",
							"protocol": "https",
							"host": [
								"api",
								"{{us_or_eu}}",
								"onelogin",
								"com"
							],
							"path": [
								"api",
								"2",
								"api_authorizations",
								"{{api_auth_id}}",
								"clients"
							]
						}
					},
					"response": []
				},
				{
					"name": "8. Get Api Auth Server Clients",
					"request": {
						"auth": {
							"type": "bearer",
							"bearer": [
								{
									"key": "token",
									"value": "{{access_token}}",
									"type": "string"
								}
							]
						},
						"method": "GET",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json",
								"type": "text"
							}
						],
						"body": {
							"mode": "raw",
							"raw": ""
						},
						"url": {
							"raw": "https://api.{{us_or_eu}}.onelogin.com/api/2/api_authorizations/{{api_auth_id}}/clients",
							"protocol": "https",
							"host": [
								"api",
								"{{us_or_eu}}",
								"onelogin",
								"com"
							],
							"path": [
								"api",
								"2",
								"api_authorizations",
								"{{api_auth_id}}",
								"clients"
							]
						}
					},
					"response": []
				},
				{
					"name": "12. Update Api Auth Server Client",
					"request": {
						"auth": {
							"type": "bearer",
							"bearer": [
								{
									"key": "token",
									"value": "{{access_token}}",
									"type": "string"
								}
							]
						},
						"method": "PUT",
						"header": [
							{
								"key": "Content-Type",
								"type": "text",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n\t\"scopes\": [{{oidc_client_scope_create}},{{oidc_client_scope_delete}}]\n}"
						},
						"url": {
							"raw": "https://api.{{us_or_eu}}.onelogin.com/api/2/api_authorizations/{{api_auth_id}}/clients/{{oidc_client_app_id}}",
							"protocol": "https",
							"host": [
								"api",
								"{{us_or_eu}}",
								"onelogin",
								"com"
							],
							"path": [
								"api",
								"2",
								"api_authorizations",
								"{{api_auth_id}}",
								"clients",
								"{{oidc_client_app_id}}"
							]
						}
					},
					"response": []
				}
			]
		},
		{
			"name": "Claims",
			"item": [
				{
					"name": "10. Create Api Auth Server Role Claim",
					"request": {
						"auth": {
							"type": "bearer",
							"bearer": [
								{
									"key": "token",
									"value": "{{access_token}}",
									"type": "string"
								}
							]
						},
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json",
								"type": "text"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"name\": \"roles\",\n    \"attributes_transformations\": \"semicolon_separated_list\",\n    \"user_attribute_mappings\": \"roles\"\n}\n"
						},
						"url": {
							"raw": "https://api.{{us_or_eu}}.onelogin.com/api/2/api_authorizations/{{api_auth_id}}/claims",
							"protocol": "https",
							"host": [
								"api",
								"{{us_or_eu}}",
								"onelogin",
								"com"
							],
							"path": [
								"api",
								"2",
								"api_authorizations",
								"{{api_auth_id}}",
								"claims"
							]
						}
					},
					"response": []
				},
				{
					"name": "9. Create Api Auth Server Claim",
					"request": {
						"auth": {
							"type": "bearer",
							"bearer": [
								{
									"key": "token",
									"value": "{{access_token}}",
									"type": "string"
								}
							]
						},
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json",
								"type": "text"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"name\": \"email_address\",\n    \"user_attribute_mappings\": \"email\"\n}\n"
						},
						"url": {
							"raw": "https://api.{{us_or_eu}}.onelogin.com/api/2/api_authorizations/{{api_auth_id}}/claims",
							"protocol": "https",
							"host": [
								"api",
								"{{us_or_eu}}",
								"onelogin",
								"com"
							],
							"path": [
								"api",
								"2",
								"api_authorizations",
								"{{api_auth_id}}",
								"claims"
							]
						}
					},
					"response": []
				},
				{
					"name": "11. Get Api Auth Server Claims",
					"request": {
						"auth": {
							"type": "bearer",
							"bearer": [
								{
									"key": "token",
									"value": "{{access_token}}",
									"type": "string"
								}
							]
						},
						"method": "GET",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json",
								"type": "text"
							}
						],
						"body": {
							"mode": "raw",
							"raw": ""
						},
						"url": {
							"raw": "https://api.{{us_or_eu}}.onelogin.com/api/2/api_authorizations/{{api_auth_id}}/claims",
							"protocol": "https",
							"host": [
								"api",
								"{{us_or_eu}}",
								"onelogin",
								"com"
							],
							"path": [
								"api",
								"2",
								"api_authorizations",
								"{{api_auth_id}}",
								"claims"
							]
						}
					},
					"response": []
				}
			]
		},
		{
			"name": "1. Generate Tokens",
			"event": [
				{
					"listen": "test",
					"script": {
						"id": "98c6466f-fbf4-4cfb-a773-9201e5b697af",
						"exec": [
							"var jsonData = JSON.parse(responseBody);",
							"postman.setEnvironmentVariable(\"access_token\", jsonData.access_token);"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"auth": {
					"type": "basic",
					"basic": [
						{
							"key": "password",
							"value": "{{client_secret}}",
							"type": "string"
						},
						{
							"key": "username",
							"value": "{{client_id}}",
							"type": "string"
						}
					]
				},
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n\"grant_type\":\"client_credentials\"\n}"
				},
				"url": {
					"raw": "https://api.{{us_or_eu}}.onelogin.com/auth/oauth2/v2/token",
					"protocol": "https",
					"host": [
						"api",
						"{{us_or_eu}}",
						"onelogin",
						"com"
					],
					"path": [
						"auth",
						"oauth2",
						"v2",
						"token"
					]
				}
			},
			"response": []
		},
		{
			"name": "2. Create Api Auth Server",
			"event": [
				{
					"listen": "test",
					"script": {
						"id": "e1354c04-cf5e-451c-8192-162444d8990b",
						"exec": [
							"var jsonData = JSON.parse(responseBody);",
							"postman.setEnvironmentVariable(\"api_auth_id\", jsonData.id);"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"auth": {
					"type": "bearer",
					"bearer": [
						{
							"key": "token",
							"value": "{{access_token}}",
							"type": "string"
						}
					]
				},
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"type": "text",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": " {\n    \"name\": \" To-Do Application APIs\",\n    \"description\": \"This emulates a customer set of apis to support a To-Do application\",\n    \"configuration\": {\n      \"resource_identifier\": \"https://example.com/todo\",\n      \"audiences\": [\"https://example.com/todo\", \"https://example.com/other_service\"],\n      \"access_token_expiration_minutes\": 10,\n      \"refresh_token_expiration_minutes\": 30\n    }\n}"
				},
				"url": {
					"raw": "https://api.{{us_or_eu}}.onelogin.com/api/2/api_authorizations",
					"protocol": "https",
					"host": [
						"api",
						"{{us_or_eu}}",
						"onelogin",
						"com"
					],
					"path": [
						"api",
						"2",
						"api_authorizations"
					]
				}
			},
			"response": []
		},
		{
			"name": "3. Get Api Auth Server",
			"request": {
				"auth": {
					"type": "bearer",
					"bearer": [
						{
							"key": "token",
							"value": "{{access_token}}",
							"type": "string"
						}
					]
				},
				"method": "GET",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": ""
				},
				"url": {
					"raw": "https://api.{{us_or_eu}}.onelogin.com/api/2/api_authorizations/{{api_auth_id}}",
					"protocol": "https",
					"host": [
						"api",
						"{{us_or_eu}}",
						"onelogin",
						"com"
					],
					"path": [
						"api",
						"2",
						"api_authorizations",
						"{{api_auth_id}}"
					]
				}
			},
			"response": []
		},
		{
			"name": "List Api Auth Servers",
			"request": {
				"auth": {
					"type": "bearer",
					"bearer": [
						{
							"key": "token",
							"value": "{{access_token}}",
							"type": "string"
						}
					]
				},
				"method": "GET",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": ""
				},
				"url": {
					"raw": "https://api.{{us_or_eu}}.onelogin.com/api/2/api_authorizations",
					"protocol": "https",
					"host": [
						"api",
						"{{us_or_eu}}",
						"onelogin",
						"com"
					],
					"path": [
						"api",
						"2",
						"api_authorizations"
					]
				}
			},
			"response": []
		},
		{
			"name": "xx Delete Api Auth Server",
			"request": {
				"auth": {
					"type": "bearer",
					"bearer": [
						{
							"key": "token",
							"value": "{{access_token}}",
							"type": "string"
						}
					]
				},
				"method": "DELETE",
				"header": [
					{
						"key": "Content-Type",
						"type": "text",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n\t\"scopes\": [51,53]\n}"
				},
				"url": {
					"raw": "https://api.{{us_or_eu}}.onelogin.com/api/2/api_authorizations/{{api_auth_id}}",
					"protocol": "https",
					"host": [
						"api",
						"{{us_or_eu}}",
						"onelogin",
						"com"
					],
					"path": [
						"api",
						"2",
						"api_authorizations",
						"{{api_auth_id}}"
					]
				}
			},
			"response": []
		}
	]
}