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 5, 2024
1 parent 3111fc4 commit 1ffeb0f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,20 @@ func getToken(c *gin.Context) {
}

```
- You can also return JWT string token signed using `ABLY_KEY` as per [official ably JWT doc](https://ably.com/tutorials/jwt-authentication). When using `WithAuthURL` clientOption at client side, response contentType header should be set to either `text/plain` or `application/jwt`.

- You can also return JWT string token signed using `ABLY_KEY` as per [official ably JWT doc](https://ably.com/tutorials/jwt-authentication).
- When using `WithAuthURL` clientOption at client side, for JWT response, contentType header should be set to `text/plain` or `application/jwt`. For `ably.TokenRequest`/ `ably.TokenDetails`, set it as `application/json`.

### Using the Token auth at client side

- You provide either `WithAuthCallback` or `WithAuthURL` as a clientOption to request token.
- You can 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 +374,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 1ffeb0f

Please sign in to comment.