Adding OAuth2 authentication flow
Blackbird can support apps that require OAuth2 connections. Currently Blackbird supports the following standard flows:
To get started, implement interfaces for IOAuth2AuthorizeService
and IOAuth2TokenService
.
Then add references to these interfaces in your IApplication
.
When the OAuth2 flow is started, Blackbird calls instances of the IOAuth2AuthorizeService
and IOAuth2TokenService
using the GetInstance<T>
method of the IApplication
interface. You should implement logic to return instances of these interfaces.
Let’s see a simple implementation example:
public class SampleApplication : IApplication
{
private readonly Dictionary<Type, object> _container;
public string Name => "Sample Application";
public SampleApplication()
{
_container = LoadTypes();
}
public T GetInsance<T>()
{
return _container[typeof(T)] as T;
}
private Dictionary<Type, object> LoadTypes()
{
new Dictionary<Type, object>
{
new { IOAuth2AuthorizeService, new OAuth2AuthorizeService() },
new { IOAuth2TokenService, new OAuth2TokenService() }
}
}
}