Skip to content

Commit

Permalink
Refactored README with better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Apr 18, 2024
1 parent 438f09e commit 2f2b195
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,16 +386,16 @@ foreach (var presenceMessage in nextPage.Items)

### Authentication
- It is recommended to use `ABLY_KEY` at server side. Check [official ably auth documentation](https://ably.com/docs/auth) for more info.
- `ABLY_KEY` should not be exposed at client side where it can be used for unintentional purposes.
- `ABLY_KEY` should not be exposed at client side where it can be used for malicious purposes.
- Server can use `ABLY_KEY` for initializing the `AblyRest` instance.

```csharp
var rest = new AblyRest("API_KEY");
```
- Token requests are issued by your servers and signed using your private API key.
- This is the preferred method of authentication as no secrets are ever shared, and the token request can be issued to trusted clients without communicating with Ably.
e.g. ASP.Net server app
```csharp
// e.g. ASP.Net server endpoint
app.MapGet("/token", async() => {
string tokenRequest = await rest.Auth.CreateTokenRequestAsync();
return Content(tokenRequest, "application/json"); // make sure to set `contentType` as json.
Expand All @@ -405,7 +405,7 @@ app.MapGet("/token", async() => {

### Using the Token auth at client side

- To use `AuthCallback` create a `ClientOptions` instance and assign an appropriate delegate to the `AuthCallback` property and pass the `ClientOptions` to a new `AblyRealtime` instance.
- Create `ClientOptions` instance with `AuthCallback` property

```csharp
var options = new ClientOptions
Expand All @@ -429,11 +429,11 @@ var options = new ClientOptions
int expiresIn = 3600; // assuming jwtToken has 1 hr expiry
return new TokenDetails(jwtToken) {
Expires = DateTimeOffset.UtcNow.AddSeconds(expiresIn)
}; // jwt token will directly be used to authenticate with server.
}; // jwt token will directly be used to authenticate with ably server.
}
};
```
- Do check [official token auth documentation](https://ably.com/docs/auth/token?lang=csharp) for more information.
- Check [official token auth documentation](https://ably.com/docs/auth/token?lang=csharp) for more information.

### Fetching your application's stats

Expand Down

0 comments on commit 2f2b195

Please sign in to comment.