https://github.com/siberaindustries/odata.client.manager
OData client manager library which uses the IODataClient implementation of Simple.OData.Client to communicate with OData APIs and handles OIDC authentication as well as request versioning requirements on top.
https://github.com/siberaindustries/odata.client.manager
api authentication csharp netstandard odata rest versioning
Last synced: 3 months ago
JSON representation
OData client manager library which uses the IODataClient implementation of Simple.OData.Client to communicate with OData APIs and handles OIDC authentication as well as request versioning requirements on top.
- Host: GitHub
- URL: https://github.com/siberaindustries/odata.client.manager
- Owner: SiberaIndustries
- License: mit
- Created: 2019-10-21T21:50:13.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-30T21:18:01.000Z (about 3 years ago)
- Last Synced: 2025-03-26T06:23:41.094Z (10 months ago)
- Topics: api, authentication, csharp, netstandard, odata, rest, versioning
- Language: C#
- Homepage:
- Size: 104 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ODataClientManager
[](https://www.nuget.org/packages/OData.Client.Manager)
[](https://github.com/SiberaIndustries/OData.Client.Manager/actions?query=workflow%3A%22.NET+Core%22)
[](https://sonarcloud.io/dashboard?id=SiberaIndustries_OData.Client.Manager)
[](https://sonarcloud.io/dashboard?id=SiberaIndustries_OData.Client.Manager)
## Purpose
This repository provides a C# based OData client manager library.
The Manager uses the `IODataClient` implementation of `Simple.OData.Client` to communicate with OData APIs and is able to handle authorization and versioning requirements.
## Getting started
The easiest way to start using the `ODataManager` is to install the Nuget package:
```sh
Install-Package OData.Client.Manager
```
In the source file where you will be using `ODataManager` import the namespace:
```cs
using OData.Client.Manager;
```
### Quickstart
The following code snipped shows an example of how to use the `IODataManger` implementation.
```cs
// Create the manager
var odataEndpoint = new Uri("http://localhost:12345/api");
var manager = new ODataManager(odataEndpoint);
// Use the client of the manager (example of the typed fluent API syntax)
IEnumerable entities = await manager.Client
.For()
.FindEntriesAsync();
// Use the client of the manager (example of the dynamic fluent API syntax)
var dx = ODataDynamic.Expression;
IEnumerable entities = await manager.Client
.For(dx.Products)
.FindEntriesAsync();
```
For more information about how to use the Odata client, please read the [Simple.OData.Client documentation](https://github.com/simple-odata-client/Simple.OData.Client/wiki).
### Make use of autenticated and versioned requests
* To make use of authentication use one of the existing authenticators in the `OData.Client.Manager.Authenticators` namespace, or create your own by implementing the `IAuthenticator` interface.
* To make use of authentication, just use one of the existing managers in the `OData.Client.Manager.Versioning` namespace or create your own by implementing the `IVersioningManager` interface.
```cs
// Setup the configuration
var config = new ODataManagerConfiguration(new Uri("http://localhost:12345/api"))
{
// Authenticated requests
Authenticator = new OidcAuthenticator(new OidcSettings
{
AuthUri = new Uri("http://localhost:5000"),
ClientId = "ClientAppX",
ClientSecret = "Secret",
Username = "User",
Password = "Password",
Scope = "api1",
GrantType = "Password", // Default
DiscoveryPolicy = new DiscoveryPolicy { RequireHttps = false },
}),
// Versioned requests
VersioningManager = new QueryParamVersioningManager("1.2", "api-version")
};
// Use the configuration in the ctor of the manager
var manager = new ODataManager(config);
```
## FAQ
1. Why do I get the error `Https required`?
* OIDC endpoints must provide an encrypted connection (https) by default (except URIs of localhost). To disable this requirement, make use of the `OidcSettings` and set `RequireHttps` of the `DiscoveryPolicy` property to `false`: `settings.DiscoveryPolicy = new DiscoveryPolicy { RequireHttps = requireHttps };`.
## Links
* OData: or
* Simple.OData.Client:
* IdentityModel:
* OIDC:
## Open Source License Acknowledgements and Third-Party Copyrights
* Icon made by [Freepik](https://www.flaticon.com/authors/freepik)