# Generate a token for a service account

## Overview

[Video: Generate a token for a service account](https://www.youtube.com/watch?v=7-PjjnguL9Q)

This flow describes how to generate a token for a [service account](https://docs.ohc.network/concepts/access-governance/service-account.md). The service account uses the token to reach Care.

You also use this flow to replace a token with a new one. Care shows **Manage Token** only to the person who created the service account.

## Pre-requisites

* You created the service account. See [Create a service account](https://docs.ohc.network/flows/access-governance/service-account/create-service-account.md).
* You have the permissions listed below.

## Permissions

| Permission | Access |
| - | - |
| Can List Users in an Organizations | Opens the **Service accounts** tab of a government organization, where you find the service account. Hold it in the organization or a parent organization. By default, the Volunteer, Doctor, Nurse, Staff and Administrator roles hold it in a government organization. |

Care shows **Manage Token** only to the person who created the service account.

## Steps

### 1. Open the profile of the service account

This page starts from the **Service accounts** tab of a government organization where the service account has a role. If it has no role there, see [Add a service account to an organization or department](https://docs.ohc.network/flows/access-governance/service-account/link-service-account.md).

On your dashboard, select the **Governance** tab. Select the organization.

Select the **Service accounts** tab.

A sub-organization has its own **Service accounts** tab. To open a sub-organization, see [Open a government organization](https://docs.ohc.network/flows/access-governance/organization/view-organization-hierarchy.md).

In the row of the service account, select **View**. Care opens the profile of the service account.

The profile shows **Service account** next to the username.

![The Care screen at the step: Open the profile of the service account](/assets/images/generate-service-account-token-1-9b2bf7ec41a8b7d9bae63e98988c5dd5.webp)

### 2. Read the caution

Find the **Manage Token** section on the profile.

Note: If you did not create the service account, Care does not show **Manage Token**.

The **Caution** box lists three points:

* If you generate a new token, any older token becomes invalid.
* Care shows the token one time only. Store it securely.
* Anyone who has the token can access Care as this service account.

![The Care screen at the step: Read the caution](/assets/images/generate-service-account-token-3-bd999bbcfac7f657e8c3e22fc0f6bbbd.webp)

### 3. Generate the token

Select **Generate Token**.

Care does not ask you to confirm. While Care works, the button shows **Generating...**.

If the service account already has a token, Care deletes it and creates a new one. Give the new token to each application that used the old token.

![The Care screen at the step: Generate the token](/assets/images/generate-service-account-token-4-def06f6b2b1a96ea076b0b41a672e7ba.webp)

### 4. Copy the token

Care opens the **Token generated successfully** dialog. The token shows under **Service Account Token**.

Select the copy button. Care shows **Token copied to clipboard**.

Store the token in a secure place.

![The Care screen at the step: Copy the token](/assets/images/generate-service-account-token-5-d6e24400dff8ac650c7ed451b0d32b5f.webp)

### 5. Close the dialog

The **Important Note** in the dialog says that Care shows the token one time only.

Close the dialog only after you store the token. When you close it, Care removes the token from the page. You cannot see it again.

If you lose the token, generate a new one. The new token replaces the lost one.

![The Care screen at the step: Close the dialog](/assets/images/generate-service-account-token-7-377a86fc807c7b0fade4bc43f1cd1fbf.webp)

## Expected Outcome

* The service account has one token, and you have a copy of it.
* If the service account had an older token, Care deleted it.
* The token has no expiry date in Care. Care keeps the token until you generate a new one or revoke it.

## Related

Concepts:

* [Service account](https://docs.ohc.network/concepts/access-governance/service-account.md)
* [Organisation](https://docs.ohc.network/concepts/access-governance/organization.md)

Flows:

* [Create a service account](https://docs.ohc.network/flows/access-governance/service-account/create-service-account.md)
* [Add a service account to an organization or department](https://docs.ohc.network/flows/access-governance/service-account/link-service-account.md)
* [Revoke a service account's token](https://docs.ohc.network/flows/access-governance/service-account/revoke-service-account-token.md)
* [Change a service account's role or remove it](https://docs.ohc.network/flows/access-governance/service-account/change-or-remove-service-account.md)
