-
-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add quick tutorial for creating API keys
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.