Skip to content

Commit

Permalink
chore: add quick tutorial for creating API keys
Browse files Browse the repository at this point in the history
  • Loading branch information
psanders committed Jan 2, 2025
1 parent d47132d commit 0f3c802
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
64 changes: 64 additions & 0 deletions docs/self-hosting/first-apikeys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# First API Keys

Fonoster uses a Workspace-centric approach, meaning all operations are performed against a specific Workspace. By default, when you self-host Fonoster, it automatically creates a default Workspace along with a default username and password.

```text
Default accessKeyId: WO00000000000000000000000000000000
Default username: admin@fonoster.local
Default password: changeme
```

You will need to create API keys to log in to a Workspace and perform operations.

## Create an API Key

First create a new folder (e.g., fonoster-apikeys-demo) and navigate into it.

```bash
mkdir fonoster-apikeys-demo
cd fonoster-apikeys-demo
```

Then, initialize a new Node.js project.

```bash
npm init -y
```

Next, install the `@fonoster/sdk` package.

```bash
npm install @fonoster/sdk
```

Once the installation is complete, create a new file called `index.js` and add the following code:

```javascript
const SDK = require("@fonoster/sdk");

// Replace these with your actual values
const client = new SDK.Client({
accessKeyId: "WO00000000000000000000000000000000",
endpoint: "localhost:50051",
allowInsecure: true
});

// Use your actual username and password here
client.login("admin@fonoster.local", "changeme").then(async () => {
const apikeys = new SDK.ApiKeys(client);

apikeys.createApiKey({
role: "WORKSPACE_ADMIN",
}).then((result) => {
console.log(result);
});
});
```

Finally, run the script.

```bash
node index.js
```

If everything goes well, you should see the new API key printed to the console and you can use it to log in to your Workspace.
1 change: 1 addition & 0 deletions docs/self-hosting/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ Self-hosting Fonoster involves running Fonoster's server on your data center. Se
Check out the following sections to get started:

- [Deploy with Docker](./deploy-with-docker.md)
- [First ApiKeys to log in](./first-apikeys.md)
- [Securing the backend and APIs](./securing-the-api.md)
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0f3c802

Please sign in to comment.