Skip to content

Commit

Permalink
Merge pull request #459 from permitio/oded/per-11283-disable-scope-in…
Browse files Browse the repository at this point in the history
…-net-sdk

Update config options for dotnet SDK
  • Loading branch information
gemanor authored Dec 8, 2024
2 parents 506ef6f + 738165a commit 8c8ed7e
Showing 1 changed file with 46 additions and 17 deletions.
63 changes: 46 additions & 17 deletions docs/getting-started/_quickstart-parts/_quickstart_dotnet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,58 @@ mkdir hello-permissions-dotnet && cd hello-permissions-dotnet && dotnet new cons

1. Install the Permit.io SDK

```bash
dotnet add package Permit
```
```bash
dotnet add package Permit
```

2. Import the SDK into your code

```csharp
using PermitSDK;
using PermitSDK.Models;
```
```csharp
using PermitSDK;
using PermitSDK.Models;
```

3. Create a new instance of the SDK. <br/>
You can find instructions on getting a secret API key in the previous section.

```csharp
// This line initializes the SDK and connects your .NET app
// to the Permit.io PDP container you've set up in the previous step.
Permit permit = new Permit(
"[YOUR_API_KEY]",
"http://localhost:7766"
);

```
```csharp
// This line initializes the SDK and connects your .NET app
// to the Permit.io PDP container you've set up in the previous step.
Permit permit = new Permit(
"[YOUR_API_KEY]",
"http://localhost:7766"
);
```

1. You can also set more config options when initializing the SDK.

```csharp
// you can also set more config options
Permit permitClient = new Permit(
// the API key to use
token: "[YOUR_API_KEY]",
// the URL of the Permit.io PDP container
pdp: "http://localhost:7766",
// the tenant to use if the tenant is not provided
defaultTenant: "default",
// whether to use the default tenant if the tenant is not provided
useDefaultTenantIfEmpty: true,
// should run in debug mode
debugMode: true,
// set the log level
level: "info",
// set the log label
label: "Permitio-sdk",
// should log as JSON
logAsJson: false,
// the URL of the API (relevant for EU customers)
apiURL: "https://api.eu-central-1.permit.io",
// should raise errors (instead of the default behavior of returning false for network errors in permit checks)
raiseErrors: false,
// Optional: manual set the environment_id and project_id for the SDK client (to avoid `scope` api call)
envId: "[YOUR_ENVIRONMENT_ID]",
projectId: "[YOUR_PROJECT_ID]"
);
```

## Check for permissions using the SDK

Expand Down

0 comments on commit 8c8ed7e

Please sign in to comment.