Exemplo n.º 1
0
        async Task <string> GetAuthorizationHeader()
        {
            if (_settings.Anonymous)
            {
                return($"Client-ID {_apiKeys.ImgurClientId}");
            }

            if (string.IsNullOrWhiteSpace(_settings.AccessToken))
            {
                throw new Exception("Not logged in to Imgur");
            }

            if (_settings.IsExpired())
            {
                if (!await RefreshToken())
                {
                    throw new Exception("Failed to Refresh Imgur token");
                }
            }

            return($"Bearer {_settings.AccessToken}");
        }