예제 #1
0
        public async Task <AccessToken?> RequestTokenAsync(
            IConsoleOutput output,
            CancellationToken cancellationToken)
        {
            if (Token.HasValue())
            {
                string?scheme = null;

                if (!NoScheme.HasValue())
                {
                    scheme = Scheme.HasValue() ? Scheme.Value() !.Trim() : _defaultScheme;
                }

                return(new AccessToken(
                           Token.Value() !.Trim(),
                           scheme));
            }

            if (TokenEndpoint.HasValue() || ClientId.HasValue() || ClientSecret.HasValue())
            {
                using IActivity activity = output.WriteActivity("Request token");
                ValidateOAuthArguments(activity);
                IEnumerable <string> scopes = Scopes.HasValue()
                    ? Enumerable.Empty <string>()
                    : Scopes.Values.Where(t => t is { }).OfType <string>();