Class containing details of the OAUth request token returned by Flickr.
示例#1
0
        private async void CheckAlreadyExists() {
            var data = StorageService.Instance.Storage.RetrieveList<PassportDataModel>();
            if (data != null && data.Count > 0) {
                var dm = data[0];

                var apis = StorageService.Instance.Storage.RetrieveList<APIKeyDataModel>();
                if (apis != null && apis.Count > 0) apiKey = apis.Where(x => x.Id == dm.APIKeyFKID).FirstOrDefault();
                
                RequestToken = new OAuthRequestToken() { Token = dm.Token, TokenSecret = dm.TokenSecret };
                AccessToken = new OAuthAccessToken() {
                    Username = dm.UserName,
                    FullName = dm.FullName,
                    ScreenName = dm.ScreenName,
                    Token = dm.Token,
                    TokenSecret = dm.TokenSecret,
                    UserId = dm.UserId,
                };
                IsLoggedIn = true;

                _flickr.OAuthAccessToken = AccessToken.Token;
                _flickr.OAuthAccessTokenSecret = AccessToken.TokenSecret;

                _flickr.ApiKey = apiKey.APIKey;
                _flickr.ApiSecret = apiKey.APISecret;
                
                var p = await _flickr.PeopleGetInfoAsync(AccessToken.UserId);
                if(!p.HasError) LoggedInUser = p.Result;

                var favs = await _flickr.FavoritesGetListAsync(AccessToken.UserId);
                if (!favs.HasError) Favourites = favs.Result;

            }
        }
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            Flickr f = FlickrManager.GetInstance();

            // obtain the request token from Flickr
            f.OAuthGetRequestTokenAsync(callbackUrl, r =>
            {
                // Check if an error was returned
                if (r.Error != null)
                {
                    Dispatcher.BeginInvoke(() => { MessageBox.Show("An error occurred getting the request token: " + r.Error.Message); });
                    return;
                }

                // Get the request token
                requestToken = r.Result;

                // get Authorization url
                string url = f.OAuthCalculateAuthorizationUrl(requestToken.Token, AuthLevel.Write);
                // Replace www.flickr.com with m.flickr.com for mobile version
                // url = url.Replace("https://www.flickr.com", "http://www.flickr.com");

                // Navigate to url
                Dispatcher.BeginInvoke(() => { WebBrowser1.Navigate(new Uri(url)); });

            });
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Create your application here
            SetContentView (Resource.Layout.Authentication);

            var webView = FindViewById<WebView> (Resource.Id.webView1);
            webView.Settings.JavaScriptEnabled = true;
            webView.SetWebViewClient (new MyWebViewClient (this));

            var flickr = FlickrManager.GetInstance (this);

            flickr.OAuthGetRequestTokenAsync (callbackUrl, r => {

                RunOnUiThread (() => {

                    if (r.Error != null) {
                        Console.WriteLine ("Error " + r.Error.Message);
                        SetResult (Result.Canceled);
                        Finish ();
                        return;
                    }

                    requestToken = r.Result;
                    string url = flickr.OAuthCalculateAuthorizationUrl (requestToken.Token, AuthLevel.Write);
                    url = url.Replace ("www.flickr.com", "m.flickr.com");
                    webView.LoadUrl (url);

                });

            });
        }
        /// <summary>
        /// Returns an access token for the given request token, secret and authorization verifier.
        /// </summary>
        /// <param name="requestToken"></param>
        /// <param name="verifier"></param>
        /// <param name="callback"></param>
        async public Task<bool> OAuthGetAccessTokenAsync(OAuthRequestToken requestToken, string verifier, Action<FlickrResult<OAuthAccessToken>> callback)
        {
            OAuthGetAccessTokenAsync(requestToken.Token, requestToken.TokenSecret, verifier, callback);

            return true;

        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            webView.Opaque = false;
            webView.BackgroundColor = UIColor.Clear;

            View.BackgroundColor = UIColor.FromPatternImage (new UIImage ("Images/bg-gunmetal.jpg"));

            webView.Delegate = new AuthenticationWebViewDelegate (this);

            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;

            var flickr = FlickrManager.GetInstance ();
            flickr.OAuthGetRequestTokenAsync (callbackUrl, r => {

                InvokeOnMainThread (() => {
                    if (r.Error != null) {
                        Console.WriteLine ("Error " + r.Error.Message);
                        return;
                    }

                    requestToken = r.Result;

                    string url = flickr.OAuthCalculateAuthorizationUrl (requestToken.Token, AuthLevel.Write);
                    url = url.Replace ("www.flickr.com", "m.flickr.com");
                    webView.LoadRequest (new NSUrlRequest (new NSUrl (url)));
                });

            });

            // Perform any additional setup after loading the view, typically from a nib.
        }
示例#6
0
 /// <summary>
 /// Parses a URL parameter encoded string and returns a new <see cref="OAuthRequestToken"/>
 /// </summary>
 /// <param name="response">A URL parameter encoded string, e.g. "oauth_token=ABC&amp;oauth_token_secret=DEF".</param>
 /// <returns></returns>
 public static OAuthRequestToken ParseResponse(string response)
 {
     Dictionary<string, string> parameters = UtilityMethods.StringToDictionary(response);
     OAuthRequestToken token = new OAuthRequestToken();
     token.Token = parameters["oauth_token"];
     token.TokenSecret = parameters["oauth_token_secret"];
     return token;
 }
示例#7
0
        /// <summary>
        /// Parses a URL parameter encoded string and returns a new <see cref="OAuthRequestToken"/>
        /// </summary>
        /// <param name="response">A URL parameter encoded string, e.g. "oauth_token=ABC&amp;oauth_token_secret=DEF".</param>
        /// <returns></returns>
        public static OAuthRequestToken ParseResponse(string response)
        {
            Dictionary <string, string> parameters = UtilityMethods.StringToDictionary(response);
            OAuthRequestToken           token      = new OAuthRequestToken();

            token.Token       = parameters["oauth_token"];
            token.TokenSecret = parameters["oauth_token_secret"];
            return(token);
        }
示例#8
0
 /// <summary>
 /// Log in to Flickr
 /// </summary>
 void Login()
 {
     requestToken = StatusForm.Instance.Flickr.OAuthGetRequestToken("oob");
     string url = StatusForm.Instance.Flickr.OAuthCalculateAuthorizationUrl(requestToken.Token, AuthLevel.Write);
     System.Diagnostics.Process.Start(url);
     VerifierLabel.Visible = true;
     VerifierCode.Visible = true;
     VerifierCode.Focus();
 }
        private void AuthenticateButton_Click(object sender, EventArgs e)
        {
            Flickr f = FlickrManager.GetInstance();
            requestToken = f.OAuthGetRequestToken("oob");

            string url = f.OAuthCalculateAuthorizationUrl(requestToken.Token, AuthLevel.Write);

            System.Diagnostics.Process.Start(url);

            Step2GroupBox.Enabled = true;
        }
示例#10
0
        /// <summary>
        /// Get an <see cref="OAuthRequestToken"/> for the given callback URL.
        /// </summary>
        /// <remarks>Specify 'oob' as the callback for no callback to be performed.</remarks>
        /// <param name="callback">The callback Uri, or 'oob' if no callback is to be performed.</param>
        /// <returns></returns>
        public OAuthRequestToken OAuthGetRequestToken(string callback)
        {
            string url = "http://www.flickr.com/services/oauth/request_token";

            Dictionary <string, string> parameters = OAuthGetBasicParameters();

            parameters.Add("oauth_callback", callback);

            string sig = OAuthCalculateSignature("POST", url, parameters, null);

            parameters.Add("oauth_signature", sig);

            string response = FlickrResponder.GetDataResponse(this, url, parameters);;

            return(OAuthRequestToken.ParseResponse(response));
        }
示例#11
0
        public void OAuthGetAccessTokenBasicTest()
        {
            Flickr f = TestData.GetSignedInstance();

            OAuthRequestToken requestToken = new OAuthRequestToken();
            requestToken.Token = TestData.RequestToken;
            requestToken.TokenSecret = TestData.RequestTokenSecret;
            string verifier = "736-824-579";

            OAuthAccessToken accessToken = f.OAuthGetAccessToken(requestToken, verifier);

            Console.WriteLine("access token = " + accessToken.Token);
            Console.WriteLine("access token secret = " + accessToken.TokenSecret);

            TestData.AccessToken = accessToken.Token;
            TestData.AccessTokenSecret = accessToken.TokenSecret;
        }
示例#12
0
 public ActionResult AuthCallback(string id, string oauth_token, string oauth_verifier)
 {
     var artist = _artistRepository.FindByToken(id);
     var requestToken = new OAuthRequestToken()
         {
             Token = artist.FlickrInfo.RequestToken,
             TokenSecret = artist.FlickrInfo.RequestSecret
         };
     var access = _flickrApi.GetAccessToken(requestToken, oauth_verifier);
     MvcApplication.CommandExecutor.ExecuteCommand(new AuthenticateWithFlickrCommand()
                                                       {
                                                           ArtistId = artist.Id,
                                                           Token = access.Token,
                                                           Secret = access.TokenSecret
                                                       });
     return View("Success");
 }
        public async Task <OAuthRequestToken> OAuthRequestTokenAsync(string callbackUrl)
        {
            const string url = "https://www.flickr.com/services/oauth/request_token";

            IDictionary <string, string> parameters = new Dictionary <string, string>();

            FlickrResponder.OAuthGetBasicParameters(parameters);
            parameters.Add("oauth_callback", callbackUrl);
            parameters.Add("oauth_consumer_key", ApiKey);

            var sig = OAuthCalculateSignature("POST", url, parameters, null);

            parameters.Add("oauth_signature", sig);

            var data       = FlickrResponder.OAuthCalculatePostData(parameters);
            var authHeader = FlickrResponder.OAuthCalculateAuthHeader(parameters);

            var response = await FlickrResponder.DownloadDataAsync("POST", url, data, null, authHeader);

            return(OAuthRequestToken.ParseResponse(response));
        }
 private void StartAuthProcess()
 {
     Flickr f = MyFlickr.getFlickr();
     f.OAuthGetRequestTokenAsync(CALL_BACK, (tok) =>
     {
         if (tok.HasError)
             TextBox1.Text = tok.Error.Message;
         else
         {
             requestToken = tok.Result;
             string url = f.OAuthCalculateAuthorizationUrl(requestToken.Token, AuthLevel.Write);
             WebBrowser1.Visibility = Visibility.Visible;
             WebBrowser1.Navigate(new Uri(url));
         }
     });
 }
示例#15
0
        public async void RequestAuthorization()
        {
            
            //1. GET THE OAUTH REQUEST TOKEN
            //2. CONSTRUCT A URL & LAUNCH IT TO GET AN "AUTHORIZATION" TOKEN
            await _flickr.OAuthGetRequestTokenAsync("oob", async (x) =>  //{} new Action<FlickrResult<OAuthRequestToken>>(x =>
            {
                
                if (!x.HasError)
                {
                    _rt = x.Result;
                    string url = _flickr.OAuthCalculateAuthorizationUrl(_rt.Token, FlickrNet.AuthLevel.Write);
                    try
                    {
                        await _dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
                        {
                            ////await Windows.System.Launcher.LaunchUriAsync(new Uri(url), new Windows.System.LauncherOptions() { DisplayApplicationPicker = true });
                            //grdWebView.Visibility = Visibility.Visible;
                            //tbConfirmationCode.Visibility = Visibility.Visible;
                            //wvLoginRequest.Source = new Uri(url);

                        });


                        await _dispatcher.RunAsync(
                            Windows.UI.Core.CoreDispatcherPriority.High,
                            new Windows.UI.Core.DispatchedHandler(() =>
                            {
                                AuthorizationUrl = url;
                                if (ChangeState != null) ChangeState("RequestGiven", EventArgs.Empty);
                                
                            })
                        );
                    }
                    catch (Exception ex)
                    {
                        var m = ex.Message;
                    }
                };
            });


        }
示例#16
0
        private async void ctlApiEditor_SaveComplete(object sender, EventArgs e)
        {
            apiKey = ctlApiEditor.APIKey;

            try
            {
                _flickr.ApiKey = apiKey.APIKey;
                _flickr.ApiSecret = apiKey.APISecret;
                

                // Acquiring a request token
                TimeSpan SinceEpoch = DateTime.UtcNow - new DateTime(1970, 1, 1);
                Random Rand = new Random();
                String FlickrUrl = "https://secure.flickr.com/services/oauth/request_token";
                Int32 Nonce = Rand.Next(1000000000);

                // Compute base signature string and sign it.
                // This is a common operation that is required for all requests even after the token is obtained.
                // Parameters need to be sorted in alphabetical order
                // Keys and values should be URL Encoded.
                String SigBaseStringParams = "oauth_callback=" + Uri.EscapeDataString(apiKey.APICallbackUrl);
                SigBaseStringParams += "&" + "oauth_consumer_key=" + apiKey.APIKey;
                SigBaseStringParams += "&" + "oauth_nonce=" + Nonce.ToString();
                SigBaseStringParams += "&" + "oauth_signature_method=HMAC-SHA1";
                SigBaseStringParams += "&" + "oauth_timestamp=" + Math.Round(SinceEpoch.TotalSeconds);
                SigBaseStringParams += "&" + "oauth_version=1.0";
                String SigBaseString = "GET&";
                SigBaseString += Uri.EscapeDataString(FlickrUrl) + "&" + Uri.EscapeDataString(SigBaseStringParams);

                IBuffer KeyMaterial = CryptographicBuffer.ConvertStringToBinary(apiKey.APISecret + "&", BinaryStringEncoding.Utf8);
                MacAlgorithmProvider HmacSha1Provider = MacAlgorithmProvider.OpenAlgorithm("HMAC_SHA1");
                CryptographicKey MacKey = HmacSha1Provider.CreateKey(KeyMaterial);
                IBuffer DataToBeSigned = CryptographicBuffer.ConvertStringToBinary(SigBaseString, BinaryStringEncoding.Utf8);
                IBuffer SignatureBuffer = CryptographicEngine.Sign(MacKey, DataToBeSigned);
                String Signature = CryptographicBuffer.EncodeToBase64String(SignatureBuffer);

                FlickrUrl += "?" + SigBaseStringParams + "&oauth_signature=" + Uri.EscapeDataString(Signature);
                string GetResponse = await SendDataAsync(FlickrUrl);
                //rootPage.NotifyUser("Received Data: " + GetResponse, NotifyType.StatusMessage);


                if (GetResponse != null)
                {
                    String oauth_token = null;
                    String oauth_token_secret = null;
                    String[] keyValPairs = GetResponse.Split('&');

                    for (int i = 0; i < keyValPairs.Length; i++)
                    {
                        String[] splits = keyValPairs[i].Split('=');
                        switch (splits[0])
                        {
                            case "oauth_token":
                                oauth_token = splits[1];
                                break;
                            case "oauth_token_secret":
                                oauth_token_secret = splits[1];
                                break;
                        }
                    }

                    RequestToken = new OAuthRequestToken() { Token = oauth_token, TokenSecret = oauth_token_secret };

                    if (oauth_token != null)
                    {
                        FlickrUrl = "https://secure.flickr.com/services/oauth/authorize?oauth_token=" + oauth_token + "&perms=read";
                        System.Uri StartUri = new Uri(FlickrUrl);
                        System.Uri EndUri = new Uri(apiKey.APICallbackUrl.Contains("http") ? apiKey.APICallbackUrl : $"http://{apiKey.APICallbackUrl}");

                        //rootPage.NotifyUser("Navigating to: " + FlickrUrl, NotifyType.StatusMessage);
                        WebAuthenticationResult WebAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(
                                                                WebAuthenticationOptions.None,
                                                                StartUri,
                                                                EndUri);
                        if (WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
                        {
                            OutputToken(WebAuthenticationResult.ResponseData.ToString());
                            String[] partsa = WebAuthenticationResult.ResponseData.ToString().Split('?');
                            String[] partsb = partsa[1].Split('&');

                            var xoauth_token = "";
                            var xoauth_verifier = "";

                            for (int i = 0; i < partsb.Length; i++)
                            {
                                String[] partsc = partsb[i].Split('=');
                                switch (partsc[0])
                                {
                                    case "oauth_token":
                                        xoauth_token = partsc[1];
                                        break;
                                    case "oauth_verifier":
                                        xoauth_verifier = partsc[1];
                                        break;
                                }
                            }


                            var rat = await _flickr.OAuthGetAccessTokenAsync(RequestToken, xoauth_verifier);
                            if (!rat.HasError)
                            {
                                AccessToken = rat.Result;

                                var dm = new PassportDataModel();
                                dm.Token = AccessToken.Token;
                                dm.TokenSecret = AccessToken.TokenSecret;
                                dm.Verifier = xoauth_verifier;
                                dm.PassType = "Flickr";

                                dm.UserId = AccessToken.UserId;
                                dm.UserName = AccessToken.Username;
                                dm.FullName = AccessToken.FullName;
                                dm.ScreenName = AccessToken.ScreenName;

                                dm.APIKeyFKID = apiKey.Id;


                                StorageService.Instance.Storage.Insert(dm);
                            }

                        }
                        else if (WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.ErrorHttp)
                        {
                            OutputToken("HTTP Error returned by AuthenticateAsync() : " + WebAuthenticationResult.ResponseErrorDetail.ToString());
                        }
                        else
                        {
                            OutputToken("Error returned by AuthenticateAsync() : " + WebAuthenticationResult.ResponseStatus.ToString());
                        }
                    }
                }
            }
            catch //(Exception Error)
            {
                //rootPage.NotifyUser(Error.Message, NotifyType.ErrorMessage);
            }
        }
示例#17
0
 public OAuthAccessToken GetAccessToken(OAuthRequestToken token, string verifier)
 {
     var access = _flickr.OAuthGetAccessToken(token, verifier);
     return access;
 }
示例#18
0
 /// <summary>
 /// Returns an access token for the given request token, secret and authorization verifier.
 /// </summary>
 /// <param name="requestToken"></param>
 /// <param name="verifier"></param>
 /// <returns></returns>
 public OAuthAccessToken OAuthGetAccessToken(OAuthRequestToken requestToken, string verifier)
 {
     return OAuthGetAccessToken(requestToken.Token, requestToken.TokenSecret, verifier);
 }
示例#19
0
 /// <summary>
 /// Returns an access token for the given request token, secret and authorization verifier.
 /// </summary>
 /// <param name="requestToken"></param>
 /// <param name="verifier"></param>
 /// <param name="callback"></param>
 public async Task<FlickrResult<OAuthAccessToken>> OAuthGetAccessTokenAsync(OAuthRequestToken requestToken, string verifier)
 {
     return await OAuthGetAccessTokenAsync(requestToken.Token, requestToken.TokenSecret, verifier);
     
 }
        private async void RequestAuthorization()
        {
            ////GET FROB
            //flickr.AuthGetFrobAsync(new Action<FlickrNet.FlickrResult<string>>(x=>{

            //    if (x.Result != null)
            //    {
            //        frob = x.Result;

            //        //USE FROB TO GET URL FOR USER AUTHENTICATION
            //        string url = flickr.AuthCalcUrl(frob, FlickrNet.AuthLevel.Write);
            //        Windows.System.Launcher.LaunchDefaultProgram(new Uri(url));

            //        Dispatcher.Invoke(Windows.UI.Core.CoreDispatcherPriority.High, new Windows.UI.Core.InvokedHandler((r,a) => {
            //            butRequestAuthorization.IsEnabled = false;
            //            butAuthorizationGiven.IsEnabled = true;
            //        }), this, null);

            //    }
            //}));


            //1. GET THE OAUTH REQUEST TOKEN
            //2. CONSTRUCT A URL & LAUNCH IT TO GET AN "AUTHORIZATION" TOKEN
            await _flickr.OAuthGetRequestTokenAsync("oob", async (x)=>  //{} new Action<FlickrResult<OAuthRequestToken>>(x =>
            {

                if (!x.HasError)
                {
                    rt = x.Result;
                    string url = _flickr.OAuthCalculateAuthorizationUrl(rt.Token, FlickrNet.AuthLevel.Write);
                    try
                    {
                        await Windows.System.Launcher.LaunchUriAsync(new Uri(url), new Windows.System.LauncherOptions() { DisplayApplicationPicker = true });
                        
                        Dispatcher.RunAsync(
                            Windows.UI.Core.CoreDispatcherPriority.High, 
                            new Windows.UI.Core.DispatchedHandler(() =>
                                {
                                    butLoginRequest.Visibility = Visibility.Collapsed;
                                    butLoginConfirm.Visibility = Visibility.Visible;
                                    //butRequestAuthorization.IsEnabled = false;
                                    //butAuthorizationGiven.IsEnabled = true;
                                    //txtOAuthVerificationCode.IsEnabled = true;
                                })
                            );
                    }
                    catch (Exception ex)
                    {
                        var m = ex.Message;
                    }
                };
            });


        }
示例#21
0
        public void Authenticate()
        {
            requestToken = Instance.OAuthGetRequestToken("oob");

            url = Instance.OAuthCalculateAuthorizationUrl(requestToken.Token, AuthLevel.Write);
        }
 /// <summary>
 /// Returns an access token for the given request token, secret and authorization verifier.
 /// </summary>
 /// <param name="requestToken"></param>
 /// <param name="verifier"></param>
 /// <param name="callback"></param>
 public void OAuthGetAccessTokenAsync(OAuthRequestToken requestToken, string verifier, Action<FlickrResult<OAuthAccessToken>> callback)
 {
     OAuthGetAccessTokenAsync(requestToken.Token, requestToken.TokenSecret, verifier, callback);
 }
示例#23
0
        /// <summary>
        /// Returns an access token for the given request token, secret and authorization verifier.
        /// </summary>
        /// <param name="requestToken"></param>
        /// <param name="verifier"></param>
        /// <param name="callback"></param>
        async public Task <bool> OAuthGetAccessTokenAsync(OAuthRequestToken requestToken, string verifier, Action <FlickrResult <OAuthAccessToken> > callback)
        {
            OAuthGetAccessTokenAsync(requestToken.Token, requestToken.TokenSecret, verifier, callback);

            return(true);
        }
示例#24
0
 /// <summary>
 /// Returns an access token for the given request token, secret and authorization verifier.
 /// </summary>
 /// <param name="requestToken"></param>
 /// <param name="verifier"></param>
 /// <returns></returns>
 public OAuthAccessToken OAuthGetAccessToken(OAuthRequestToken requestToken, string verifier)
 {
     return(OAuthGetAccessToken(requestToken.Token, requestToken.TokenSecret, verifier));
 }
示例#25
0
 /// <summary>
 /// Returns an access token for the given request token, secret and authorization verifier.
 /// </summary>
 /// <param name="requestToken"></param>
 /// <param name="verifier"></param>
 /// <param name="callback"></param>
 public async Task <FlickrResult <OAuthAccessToken> > OAuthGetAccessTokenAsync(OAuthRequestToken requestToken, string verifier)
 {
     return(await OAuthGetAccessTokenAsync(requestToken.Token, requestToken.TokenSecret, verifier));
 }
示例#26
0
        private void InitializeAuthentication()
        {
            _flickr.OAuthAccessToken = null;
            _flickr.OAuthAccessTokenSecret = null;
            _requestToken = _flickr.OAuthGetRequestToken("oob");
            var authUrl = _flickr.OAuthCalculateAuthorizationUrl(_requestToken.Token, AuthLevel.Write);

            Process.Start(authUrl);
        }
示例#27
0
 /// <summary>
 /// Returns an access token for the given request token, secret and authorization verifier.
 /// </summary>
 /// <param name="requestToken"></param>
 /// <param name="verifier"></param>
 /// <param name="callback"></param>
 public void OAuthGetAccessTokenAsync(OAuthRequestToken requestToken, string verifier, Action <FlickrResult <OAuthAccessToken> > callback)
 {
     OAuthGetAccessTokenAsync(requestToken.Token, requestToken.TokenSecret, verifier, callback);
 }
示例#28
0
文件: SplashVM.cs 项目: liquidboy/X
        private async void PopulatePassportData()
        {
            if (apiKey == null) { IsLoginVisible = Visibility.Visible; return; }

            var data = StorageService.Instance.Storage.RetrieveList<PassportDataModel>();
            if (data != null && data.Count > 0)
            {
                IsLoginVisible = Visibility.Visible;
                IsTabsVisible = Visibility.Collapsed;

                var dm = data.Where(x => x.PassType == GroupingType).FirstOrDefault();
                if (dm != null) {
                    IsLoginVisible = Visibility.Collapsed;
                    IsTabsVisible = Visibility.Visible;
                    
                    RequestToken = new OAuthRequestToken() { Token = dm.Token, TokenSecret = dm.TokenSecret };
                    AccessToken = new OAuthAccessToken()
                    {
                        Username = dm.UserName,
                        FullName = dm.FullName,
                        ScreenName = dm.ScreenName,
                        Token = dm.Token,
                        TokenSecret = dm.TokenSecret,
                        UserId = dm.UserId,
                    };
                    //IsLoggedIn = true;

                    _flickr.OAuthAccessToken = AccessToken.Token;
                    _flickr.OAuthAccessTokenSecret = AccessToken.TokenSecret;

                    _flickr.ApiKey = apiKey.APIKey;
                    _flickr.ApiSecret = apiKey.APISecret;

                    var p = await _flickr.PeopleGetInfoAsync(AccessToken.UserId);
                    if (!p.HasError) LoggedInUser = p.Result;

                    var favs = await _flickr.FavoritesGetListAsync(AccessToken.UserId);
                    if (!favs.HasError) {
                        var temp = new PhotoCollection();
                        foreach (var fav in favs.Result)
                        {
                            //fav.MachineTags = "https://c1.staticflickr.com/1/523/buddyicons/118877287@N03_l.jpg?1437204284#118877287@N03";
                            fav.MachineTags = $"https://c1.staticflickr.com/{fav.IconFarm}/{fav.IconServer}/buddyicons/{fav.UserId}.jpg?";
                            temp.Add(fav);
                        }
                        FavouritePhotos = temp;
                    }
                    
                }
            }
            else {
                //no passport so show login button
                IsLoginVisible = Visibility.Visible;
                IsTabsVisible = Visibility.Collapsed;
            }
        }