mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-04 16:40:41 +00:00
Document getAuthToken for web based login (#2418)
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled
This commit is contained in:
committed by
GitHub
parent
15bd2ec5ac
commit
da0907d3c5
@@ -35,6 +35,8 @@ puter.ai.chat(`Why did the chicken cross the road?`).then(console.log);
|
||||
|
||||
#### Use in Node.js
|
||||
|
||||
Initialize Puter.js with your auth token using the `init` function:
|
||||
|
||||
```js
|
||||
import { init } from "@heyputer/puter.js/src/init.cjs";
|
||||
const puter = init(process.env.puterAuthToken);
|
||||
@@ -43,6 +45,15 @@ const puter = init(process.env.puterAuthToken);
|
||||
puter.ai.chat("What color was Napoleon's white horse?").then(console.log);
|
||||
```
|
||||
|
||||
If your environment has browser access, you can obtain a token via browser login:
|
||||
|
||||
```js
|
||||
import { init, getAuthToken } from "@heyputer/puter.js/src/init.cjs";
|
||||
|
||||
const authToken = await getAuthToken(); // performs browser based auth
|
||||
const puter = init(authToken);
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
<div class="example-content" data-section="cdn">
|
||||
|
||||
@@ -87,8 +87,6 @@ The Puter ecosystem hosts over 60,000 live applications, from essential tools li
|
||||
|
||||
## **Node.js**
|
||||
|
||||
> **Note:** Node.js support is currently in beta.
|
||||
|
||||
Puter.js works seamlessly in Node.js environments, allowing you to integrate AI, databases, and cloud storage with your Node.js applications. This makes it ideal for building backend services and APIs, performing server-side data processing, or creating CLI tools and automation scripts.
|
||||
|
||||
```js
|
||||
@@ -106,6 +104,8 @@ puter.ai.chat("What color was Napoleon's white horse?").then((response) => {
|
||||
|
||||
Get started quickly with the [Node.js + Express template](https://github.com/HeyPuter/node.js-express.js).
|
||||
|
||||
<div class="info">If your environment has browser access (e.g. CLI tools), you can use <code>getAuthToken()</code> to obtain a token via web-based login.</div>
|
||||
|
||||
## **Serverless Workers**
|
||||
|
||||
[Serverless Workers](/Workers/) let you run HTTP servers and backend APIs.
|
||||
|
||||
Reference in New Issue
Block a user