Wrapper Api Gcm client
License
—
Deps
6
Install Size
—
Vulns
✓ 0
Published
Nov 6, 2024
$ dotnet add package Amilon.GCM.ClientThis client allows you to connect and use Amilon's GCM API services.
You can configure the authentication parameters in the appsettings.json. Depending on your authentication type, you can configure
or/and optionally
"GCM_API_Client": {
"Environment": "STG",
"ClientId": "your-client-id",
"ClientSecret": "your-client-secret",
"UserName": "your-username",
"Password": "your-password",
"Version": "2",
"GrantType": "password",
"Timeout": 60000
}
You can configure the client in your app through Dependency Injection
public IConfiguration Configuration { get; }
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public void ConfigureServices(IServiceCollection services)
{
services.AddGCMClient(Configuration);
}
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddGCMClient(builder.Configuration);
You can configure the authentication parameters in the appsettings.json. Depending on your authentication type, you can configure
or/and optionally
In this Multi Tenant mode, you can customize the appSettings to your own needs, it does not have to use a specific structure as the client will be initialized manually using the needed parameters in the AddGCMClient method call.
"GCM_API_Client": {
"Environment": "STG",
"Version": "2",
"GrantType": "password",
"Timeout": 60000
},
"MultiTenant": [
{
"ClientId": "your-client-id_1",
"ClientSecret": "your-client-secret_1",
"GCMCredentials": {
"UserName": "your-user-name_1",
"Password": "your-password_1"
}
},
{
"ClientId": "your-client-id_2",
"ClientSecret": "your-client-secret_2",
"GCMCredentials": {
"UserName": "your-user-name_2",
"Password": "your-password_2"
}
},
]
You can configure the client in your app through Dependency Injection. MultiTenantHelper is a placeholder for a class you can make in order to get the specific credentials for a specific ClientId.
public IConfiguration Configuration { get; }
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public void ConfigureServices(IServiceCollection services)
{
var gcmConfig = Configuration.GetSection("GCM_API_Client").Get<GCMConfig>();
services.AddGCMClient(_ =>
{
var config = new GCMConfig();
var gcmCredentials = MultiTenantHelper.GetGCMCredentials();
config.ClientId = gcmCredentials.ClientId;
config.ClientSecret = gcmCredentials.ClientSecret;
config.GrantType = gcmConfig.GrantType;
config.Version = gcmConfig.Version;
config.Password = gcmCredentials.Password;
config.UserName = gcmCredentials.UserName;
return config;
}, gcmConfig.Environment, gcmConfig.Timeout);
}
var builder = Host.CreateApplicationBuilder(args);
var gcmConfig = builder.Configuration.GetSection("GCM_API_Client").Get<GCMConfig>();
builder.Services.AddGCMClient(_ =>
{
var config = new gcmConfig();
var gcmCredentials = MultiTenantHelper.GetGCMCredentials();
config.ClientId = gcmConfig.ClientId;
config.ClientSecret = gcmConfig.ClientSecret;
config.GrantType = gcmConfig.GrantType;
config.Version = gcmConfig.Version;
config.Password = gcmCredentials.Password;
config.UserName = gcmCredentials.UserName;
return config;
}, gcmConfig.Environment, gcmConfig.Timeout);