public static async Task AuthPocket(string accessCode = null)
        {
            if (string.IsNullOrEmpty(accessCode) && AuthBrowserAction != null)
            {
                pocketClient = new PocketClient(POCKETCONSUMERKEY)
                {
                    CallbackUri = "https://derekantrican.github.io/authsuccess"
                };
                string requestCode = await pocketClient.GetRequestCode();

                AuthBrowserAction.Invoke(pocketClient.GenerateAuthenticationUri().ToString());

                PocketUser user;
                while (true)
                {
                    try
                    {
                        user = await pocketClient.GetUser(requestCode);

                        break;
                    }
                    catch { }
                    Thread.Sleep(500);
                }

                accessCode = user.Code;
                SaveAccessCodeAction?.Invoke(accessCode);
            }

            pocketClient = new PocketClient(POCKETCONSUMERKEY, accessCode);
        }
示例#2
0
        private static async Task <int> Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var    _client     = new PocketClient(_config.PocketConsumerKey, callbackUri: _config.PocketRedirectUri);
            string requestCode = await _client.GetRequestCode();

            Console.WriteLine(_client.GenerateRegistrationUri(requestCode).ToString());
            Console.WriteLine("Press enter after authorizing app...");
            Console.ReadLine();
            PocketUser pocketUser = await _client.GetUser(requestCode);

            IUserService userService = UserService.BuildUserService(_config.StorageConnectionString);

            Console.WriteLine("Input your kindle email:");
            var kindleEmail = Console.ReadLine();

            var user = new User()
            {
                AccessCode         = pocketUser.Code,
                PocketUsername     = pocketUser.Username,
                KindleEmail        = kindleEmail,
                LastProcessingDate = DateTime.UtcNow
            };

            await userService.AddUserAsync(user);

            Console.WriteLine("Bye World!");
            Console.ReadLine();

            return(0);
        }
示例#3
0
        public async Task <Uri> LoginUriAsync()
        {
            client = new PocketClient(ApiKeys.Pocket, callbackUri: App.PocketProtocol);
            string requestCode = await client.GetRequestCode();

            return(client.GenerateAuthenticationUri());
        }
示例#4
0
        public static async System.Threading.Tasks.Task <IActionResult> RunAsync(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
            ExecutionContext context)
        {
            Config _config = new ConfigBuilder(context.FunctionAppDirectory).Build();

            var    _client     = new PocketClient(_config.PocketConsumerKey, callbackUri: _config.PocketRedirectUri, isMobileClient: false);
            string requestCode = await _client.GetRequestCode();

            var result = new
            {
                RequestCode      = requestCode,
                RegistrationLink = _client.GenerateRegistrationUri(requestCode)
            };

            return(new OkObjectResult(JsonConvert.SerializeObject(result)));
        }
示例#5
0
 public async Task <string> GetRequestCode()
 {
     return(await _client.GetRequestCode());
 }