Skip to content

Commit 63c2cbe

Browse files
committed
docs: Update users and tokens page
1 parent 2b5bb2e commit 63c2cbe

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

docusaurus/docs/Angular/concepts/users-and-tokens.mdx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,42 +32,45 @@ this.chatService.init(environment.apiKey, undefined, "anonymous");
3232

3333
## Generating tokens
3434

35-
Regular users require a valid JWT token to access the Stream API. Tokens can't be created securely on the client-side, so you should generate tokens on your server-side. All important information about [tokens can be found in the client documentation](https://getstream.io/chat/docs/javascript/tokens_and_authentication/?language=javascript).
35+
Regular users (all users except guests and anonymous users) require a valid JWT token to access the Stream API. Tokens can't be created securely on the client-side, so you should generate tokens on your server-side. All important information about [tokens can be found in the client documentation](https://getstream.io/chat/docs/javascript/tokens_and_authentication/?language=javascript).
3636

3737
Here is how you can provide the generated token to the Angular SDK:
3838

3939
```ts
4040
// Option 1: using a static token
4141
this.chatService.init(
4242
"<API key>",
43-
{
44-
id: "<user id>",
45-
name: "Sara",
46-
image: "url/to/image",
47-
},
43+
"<user or id>",
4844
// Example static token
4945
"eyJhbGcIOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
5046
);
5147

5248
// Option 2. using a token provider
5349
this.chatService.init(
5450
"<API key>",
55-
{
56-
id: "<user id>",
57-
name: "Sara",
58-
image: "url/to/image",
59-
},
51+
"<user or id>",
6052
// Example token provider
6153
// The SDK will call your token provider when you connect, or when the token is expired and it needs a new one
6254
// With token providers you can use short-living tokens, so we advise using this method in your production applications
6355
() => async {
64-
const token = await <HTTP call to your own backend to obtain a new token>
56+
const token = await (<HTTP call to your own backend to obtain a new token>).token;
6557

6658
return token;
6759
}
6860
);
6961
```
7062

63+
This is how you can use [developer tokens](https://getstream.io/chat/docs/javascript/tokens_and_authentication/?language=javascript#developer-tokens) with the Angular SDK:
64+
65+
```ts
66+
import { StreamChat } from "stream-chat";
67+
68+
const apiKey = "<API key>";
69+
const userId = "<user id>";
70+
const devToken = StreamChat.getInstance(apiKey).devToken(userId);
71+
this.chatService.init(apiKey, userId, devToken);
72+
```
73+
7174
## Disconnecting users
7275

7376
If your application allows connecting with different users, you should make sure to properly disconnect the previous user before connecting a new one:

0 commit comments

Comments
 (0)