mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-07 22:58:02 +00:00
docs: .net quickstart (#1683)
* fix: add .net quickstart * fix: add .net quickstart * fix: add .net quickstart * fix: add .net quickstart * fix: add .net quickstart * add syntax highlight for csharp * typo in go * fix: fix docs * Update docs/docs/quickstarts/dot-net.md Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
parent
f51f0ede5c
commit
72f0cbe813
@ -302,10 +302,6 @@ If you get stuck consider checking out our [template](https://github.com/caos/zi
|
|||||||
|
|
||||||
### Whats next?
|
### Whats next?
|
||||||
|
|
||||||
<<<<<<< HEAD:docs/docs/quickstarts/angular.md
|
|
||||||
Now you can proceed implementing our APIs to include Authorization. Refer to our [Docs](../apis/apis) or checkout our Console Code on [Github](https://github.com/caos/zitadel) which is using GRPC to access data.
|
Now you can proceed implementing our APIs to include Authorization. Refer to our [Docs](../apis/apis) or checkout our Console Code on [Github](https://github.com/caos/zitadel) which is using GRPC to access data.
|
||||||
=======
|
|
||||||
Now you can proceed implementing our APIs to include Authorization. Refer to our [Docs](introduction) or checkout our Console Code on [Github](https://github.com/caos/zitadel) which is using GRPC to access data.
|
|
||||||
>>>>>>> main:site/docs/angular/02-code.md
|
|
||||||
|
|
||||||
For more information about creating an angular application we refer to [Angular](https://angular.io/start) and for more information about the used oauth/oidc library consider reading their docs at [angular-oauth2-oidc](https://github.com/manfredsteyer/angular-oauth2-oidc).
|
For more information about creating an angular application we refer to [Angular](https://angular.io/start) and for more information about the used oauth/oidc library consider reading their docs at [angular-oauth2-oidc](https://github.com/manfredsteyer/angular-oauth2-oidc).
|
||||||
|
122
docs/docs/quickstarts/dot-net.md
Normal file
122
docs/docs/quickstarts/dot-net.md
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
---
|
||||||
|
title: .NET
|
||||||
|
---
|
||||||
|
|
||||||
|
This integration guide shows you how to integrate **ZITADEL** into your .NET application.
|
||||||
|
It demonstrates how to fetch some data from the ZITADEL management API.
|
||||||
|
|
||||||
|
At the end of the guide you should have an application able to read the details of your organisation.
|
||||||
|
|
||||||
|
If you need any other information about the .NET SDK go to the [documentation](https://caos.github.io/zitadel-net/) of the SDK itself.
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
The client [SDK](https://github.com/caos/zitadel-net) will handle all necessary OAuth 2.0 requests and send the required headers to the ZITADEL API.
|
||||||
|
All that is required, is a service account with an Org Owner (or another role, depending on the needed api requests) role assigned and its key JSON.
|
||||||
|
|
||||||
|
However, we recommend you read the guide on [how to access ZITADEL API](../guides/usage/access-zitadel-apis) and the associated guides for a basic knowledge of :
|
||||||
|
- [Recommended Authorization Flows](../guides/usage/oauth-recommended-flows)
|
||||||
|
- [Service Users](../guides/usage/serviceusers)
|
||||||
|
|
||||||
|
> Be sure to have a valid key JSON and that its service account is either ORG_OWNER or at least ORG_OWNER_VIEWER before you continue with this guide.
|
||||||
|
|
||||||
|
## .NET Setup
|
||||||
|
|
||||||
|
### Create a .NET application
|
||||||
|
|
||||||
|
Use the IDE of your choice or the command line to create a new application.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
dotnet new web
|
||||||
|
```
|
||||||
|
|
||||||
|
### Install the package
|
||||||
|
|
||||||
|
Install the package via nuget
|
||||||
|
|
||||||
|
```bash
|
||||||
|
dotnet add package Zitadel.Api
|
||||||
|
```
|
||||||
|
|
||||||
|
### Create example client
|
||||||
|
|
||||||
|
Change the program.cs file to the content below. This will create a client for the management api and call its `GetMyOrg` function.
|
||||||
|
The SDK will make sure you will have access to the API by retrieving a Bearer Token using JWT Profile with the provided scopes (`openid` and `urn:zitadel:iam:org:project:id:69234237810729019:aud`).
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
using System;
|
||||||
|
using Zitadel.Api;
|
||||||
|
using Zitadel.Authentication;
|
||||||
|
using Zitadel.Authentication.Credentials;
|
||||||
|
|
||||||
|
// no.. this key is not activated anymore ;-)
|
||||||
|
var sa = await ServiceAccount.LoadFromJsonFileAsync("./service-account.json");
|
||||||
|
var api = Clients.ManagementService(
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
// Which api endpoint (self hosted or public)
|
||||||
|
Endpoint = ZitadelDefaults.ZitadelApiEndpoint,
|
||||||
|
// The organization context (where the api calls are executed)
|
||||||
|
Organization = "74161146763996133",
|
||||||
|
// Service account authentication
|
||||||
|
ServiceAccountAuthentication = (sa, new()
|
||||||
|
{
|
||||||
|
ProjectAudiences = { ZitadelDefaults.ZitadelApiProjectId },
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
var myOrg = await api.GetMyOrgAsync(
|
||||||
|
new() {}
|
||||||
|
);
|
||||||
|
|
||||||
|
Console.WriteLine($"{myOrg.Org.Name} was created on: {myOrg.Org.Details.CreationDate} ");
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Custom ZITADEL instance
|
||||||
|
|
||||||
|
If your client will not use ZITADEL Cloud (zitadel.ch), be sure to provide the correct values for the ZITADEL ProjectID, Issuer and API options:
|
||||||
|
```csharp
|
||||||
|
|
||||||
|
// Which api endpoint (self hosted or public)
|
||||||
|
Endpoint = "api.custom.ch:443",
|
||||||
|
// Service account authentication
|
||||||
|
ServiceAccountAuthentication = (sa, new()
|
||||||
|
{
|
||||||
|
ProjectAudiences = { "ZITADEL-ProjectID" },
|
||||||
|
Endpoint = "https://issuer.custom.ch",
|
||||||
|
}),
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Test client
|
||||||
|
|
||||||
|
After you have configured everything correctly, you can simply start the example by:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
dotnet run
|
||||||
|
```
|
||||||
|
|
||||||
|
This will output something similar to:
|
||||||
|
|
||||||
|
```
|
||||||
|
ACME was created on: "2020-09-21T14:44:48.090431Z"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Completion
|
||||||
|
|
||||||
|
You have successfully used the ZITADEL .NET SDK to call the management API!
|
||||||
|
|
||||||
|
If you encountered an error (e.g. `code = PermissionDenied desc = No matching permissions found`),
|
||||||
|
ensure your service user has the required permissions by assigning the `ORG_OWNER` or `ORG_OWNER_VIEWER` role
|
||||||
|
and check the mentioned [guides](#prerequisites) at the beginning.
|
||||||
|
|
||||||
|
If you've run into any other problem, don't hesitate to contact us or raise an issue on [ZITADEL](https://github.com/caos/zitadel/issues) or in the [SDK](https://github.com/caos/zitadel-go/issues).
|
||||||
|
|
||||||
|
### Whats next?
|
||||||
|
|
||||||
|
Now you can proceed implementing our APIs by adding more calls.
|
||||||
|
|
||||||
|
Checkout more [examples from the SDK](https://github.com/caos/zitadel-go/blob/main/example) or refer to our [API Docs](../apis/introduction).
|
||||||
|
|
||||||
|
> This guide will be updated soon to show you how to use the SDK for your own API as well.
|
@ -5,12 +5,12 @@ title: Go
|
|||||||
This integration guide shows you how to integrate **ZITADEL** into your Go application.
|
This integration guide shows you how to integrate **ZITADEL** into your Go application.
|
||||||
It demonstrates how to fetch some data from the ZITADEL management API.
|
It demonstrates how to fetch some data from the ZITADEL management API.
|
||||||
|
|
||||||
At the end of the guide you should have an application able read the details of your organisation.
|
At the end of the guide you should have an application able to read the details of your organisation.
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
The client [SDK](https://github.com/caos/zitadel-go) will handle all necessary OAuth 2.0 requests and send the required headers to the ZITADEL API using our [OIDC client library](https://github.com/caos/oidc).
|
The client [SDK](https://github.com/caos/zitadel-go) will handle all necessary OAuth 2.0 requests and send the required headers to the ZITADEL API using our [OIDC client library](https://github.com/caos/oidc).
|
||||||
All that is required, is a service account with an Org Owner role assigned and its key JSON.
|
All that is required, is a service account with an Org Owner (or another role, depending on the needed api requests) role assigned and its key JSON.
|
||||||
|
|
||||||
However, we recommend you read the guide on [how to access ZITADEL API](../guides/usage/access-zitadel-apis) and the associated guides for a basic knowledge of :
|
However, we recommend you read the guide on [how to access ZITADEL API](../guides/usage/access-zitadel-apis) and the associated guides for a basic knowledge of :
|
||||||
- [Recommended Authorization Flows](../guides/usage/oauth-recommended-flows)
|
- [Recommended Authorization Flows](../guides/usage/oauth-recommended-flows)
|
||||||
|
@ -114,6 +114,9 @@ module.exports = {
|
|||||||
apiKey: 'bff480bce03126c2d348345647854e91',
|
apiKey: 'bff480bce03126c2d348345647854e91',
|
||||||
indexName: 'zitadel'
|
indexName: 'zitadel'
|
||||||
},
|
},
|
||||||
|
prism: {
|
||||||
|
additionalLanguages: ['csharp'],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
presets: [
|
presets: [
|
||||||
[
|
[
|
||||||
|
@ -25,7 +25,8 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
type: 'category',
|
type: 'category',
|
||||||
label: 'Backends',
|
label: 'Backends',
|
||||||
items: ['quickstarts/go'],
|
items: ['quickstarts/go', 'quickstarts/dot-net'],
|
||||||
|
collapsed: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'category',
|
type: 'category',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user