Exemple #1
0
        private async Task AuthPocketAsync()
        {
            if (!AuthPocketViaSavedAccessToken())
            {
                pocketClient = new PocketClient(Secrets.PocketAPIConsumerKey);
                Uri          callbackUri  = WebAuthenticationBroker.GetCurrentApplicationCallbackUri();
                RequestToken requestToken = await pocketClient.ObtainRequestTokenAsync(
                    callbackUri);

                Uri requestUri = pocketClient.ObtainAuthorizeRequestTokenRedirectUri(requestToken, callbackUri);
                WebAuthenticationResult result = await WebAuthenticationBroker.AuthenticateSilentlyAsync(requestUri);

                if (result.ResponseStatus != WebAuthenticationStatus.Success)
                {
                    result = await WebAuthenticationBroker.AuthenticateAsync(
                        WebAuthenticationOptions.None,
                        requestUri);
                }

                AccessToken token = await pocketClient.ObtainAccessTokenAsync(requestToken);

                ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
                string tokenString = JsonSerializer.Serialize(token);
                localSettings.Values.Add("accessToken", tokenString);
            }
        }
        public async Task ExecuteTest()
        {
            RequestToken requestToken = await _pocketClient.ObtainRequestTokenAsync(
                WebAuthenticationBroker.GetCurrentApplicationCallbackUri());

            Assert.IsNotNull(requestToken);
            Assert.IsNotNull(requestToken.Code);
            Assert.AreEqual(30, requestToken.Code.Length);
        }
Exemple #3
0
        public async Task ExecuteTestAsync()
        {
            Uri          callbackUri  = WebAuthenticationBroker.GetCurrentApplicationCallbackUri();
            RequestToken requestToken = await _pocketClient.ObtainRequestTokenAsync(callbackUri);

            Uri uri = _pocketClient.ObtainAuthorizeRequestTokenRedirectUri(requestToken, callbackUri);

            Assert.IsNotNull(uri);
            Assert.IsNotNull(uri.ToString());
        }