示例#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);
            }
        }
示例#2
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());
        }