Skip to content

Commit

Permalink
Updated README, authentication section updated with AuthURL, added fe…
Browse files Browse the repository at this point in the history
…w comments
  • Loading branch information
sacOO7 committed Sep 4, 2024
1 parent 3111fc4 commit 624a83c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,13 @@ func getToken(c *gin.Context) {
### Using the Token auth at client side

- You provide either `WithAuthCallback` or `WithAuthURL` as a clientOption to request token.
- `WithAuthUrl` automatically decodes response based on response contentType.

```go
authCallback := ably.WithAuthCallback(func(ctx context.Context, tp ably.TokenParams) (ably.Tokener, error) {
// HTTP client impl. to fetch token, you can pass tokenParams based on your requirement
// Return token of type ably.TokenDetails, ably.TokenRequest or ably.TokenString
// This may need manually decoding tokens based on the response.
token, err := requestTokenFrom(ctx, "/token");
if err != nil {
return nil, err // You can also log error here
Expand All @@ -369,7 +372,7 @@ authCallback := ably.WithAuthCallback(func(ctx context.Context, tp ably.TokenPar
if err != nil {
return nil, err // You can also log error here
}
return jwtTokenString, err // return standard jwt base64 encoded token that starts with "ey"
return ably.TokenString(jwtTokenString), err // return jwt token that starts with "ey"
})
```
- Check [official token auth documentation](https://ably.com/docs/auth/token?lang=csharp) for more information.
Expand Down

0 comments on commit 624a83c

Please sign in to comment.