| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | using Google.Apis.Json; |
| | using System; |
| | using System.IO; |
| | using System.Threading; |
| | using System.Threading.Tasks; |
| |
|
| | namespace Google.Apis.Auth.OAuth2 |
| | { |
| | |
| | |
| | |
| | public sealed class GoogleClientSecrets |
| | { |
| | |
| | [Newtonsoft.Json.JsonProperty("installed")] |
| | private ClientSecrets Installed { get; set; } |
| |
|
| | |
| | [Newtonsoft.Json.JsonProperty("web")] |
| | private ClientSecrets Web { get; set; } |
| |
|
| | |
| | public ClientSecrets Secrets |
| | { |
| | get |
| | { |
| | if (Installed == null && Web == null) |
| | { |
| | throw new InvalidOperationException( |
| | "At least one client secrets (Installed or Web) should be set"); |
| | } |
| | return Installed ?? Web; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | [Obsolete("Please use GoogleClientSecrets.FromStream which is an equivalent alternative.")] |
| | public static GoogleClientSecrets Load(Stream stream) => |
| | FromStream(stream); |
| |
|
| | |
| | public static GoogleClientSecrets FromStream(Stream stream) => |
| | NewtonsoftJsonSerializer.Instance.Deserialize<GoogleClientSecrets>(stream); |
| |
|
| | |
| | public static Task<GoogleClientSecrets> FromStreamAsync(Stream stream, CancellationToken cancellationToken = default) => |
| | NewtonsoftJsonSerializer.Instance.DeserializeAsync<GoogleClientSecrets>(stream, cancellationToken); |
| |
|
| | |
| | public static GoogleClientSecrets FromFile(string clientSecretsFilePath) |
| | { |
| | using var stream = new FileStream(clientSecretsFilePath, FileMode.Open, FileAccess.Read); |
| | return FromStream(stream); |
| | } |
| |
|
| | |
| | public static async Task<GoogleClientSecrets> FromFileAsync(string clientSecretsFilePath, CancellationToken cancellationToken = default) |
| | { |
| | using var stream = new FileStream(clientSecretsFilePath, FileMode.Open, FileAccess.Read); |
| | return await FromStreamAsync(stream, cancellationToken).ConfigureAwait(false); |
| | } |
| | } |
| | } |
| |
|