public WeightEndpoint(AccessTokenManagerBase tokenManager, UsersModel user)
 {
     _tokenManager = tokenManager;
     _user = user;
 }
 public StrengthTrainingActivitiesEndpoint(AccessTokenManagerBase tokenManager, UsersModel user)
 {
     _tokenManager = tokenManager;
     _user = user;
 }
 public DiabetesMeasurementsEndpoint(AccessTokenManagerBase tokenManager, UsersModel user)
 {
     _tokenManager = tokenManager;
     _user = user;
 }
 public RecordsEndpoint(AccessTokenManagerBase tokenManager, UsersModel user)
 {
     _tokenManager = tokenManager;
     _user = user;
 }
 public BackgroundActivitiesEndpoint(AccessTokenManagerBase tokenManager, UsersModel user)
 {
     _tokenManager = tokenManager;
     _user = user;
 }
 public NutritionEndpoint(AccessTokenManagerBase tokenManager, UsersModel user)
 {
     _tokenManager = tokenManager;
     _user = user;
 }
 public FitnessActivitiesEndpoint(AccessTokenManagerBase tokenManager, UsersModel user)
 {
     _tokenManager = tokenManager;
     _user = user;
 }
 public SettingsEndpoint(AccessTokenManagerBase tokenManager, UsersModel user)
 {
     _tokenManager = tokenManager;
     _user = user;
 }
Пример #9
0
        protected void AttemptAuth(object sender, EventArgs e)
        {
            _clientIdEntry.FetchValue();
            ClientId = _clientIdEntry.Value;
            _clientSecretEntry.FetchValue();
            ClientSecret = _clientSecretEntry.Value;
            _requestUriEntry.FetchValue();
            RequestUri = _requestUriEntry.Value;

            if ((string.IsNullOrEmpty(ClientId)) || (string.IsNullOrEmpty(ClientSecret)) || (string.IsNullOrEmpty(RequestUri)))
            {
                UIAlertView firstPageValidationAlert = new UIAlertView("Whoops!", "Please provide a Client Id, Client Secrent and Request Uri.", null, "Okay");
                firstPageValidationAlert.Show();
            }
            else
            {
                //Elements for Second Page - authorization
                var secondPage = new UIViewController();
                secondPage.Title = "Authorize";
                var authorizeWebView = new UIWebView(secondPage.View.Frame);
                secondPage.View.AddSubview(authorizeWebView);
                viewController.VisibleViewController.NavigationController.PushViewController(secondPage, true);
                authorizeWebView.LoadFinished += delegate(object s, EventArgs ev) {
                    string currentUrl = authorizeWebView.Request.Url.AbsoluteString;
                    const string CodeIdentifier = "code=";
                    if (currentUrl.Contains(CodeIdentifier))
                    {
                        //We've received an authorization code - initialize the token manager to get a create a token
                        Code = currentUrl.Substring(currentUrl.IndexOf(CodeIdentifier) + CodeIdentifier.Length);
                        TokenManager = new AccessTokenManager(ClientId, ClientSecret, RequestUri);
                        InvokeOnMainThread(() => {
                            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
                        });
                        TokenManager.InitAccessToken(Code);
                        var userRequest = new UsersEndpoint(TokenManager);
                        User = userRequest.GetUser();
                        var profileRequest = new ProfileEndpoint(TokenManager, User);
                        Profile = profileRequest.GetProfile();
                        InvokeOnMainThread(() => {
                            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
                        });
                        ShowUserAndProfile();
                    }
                };
                authorizeWebView.LoadRequest(new NSUrlRequest(new NSUrl(HealthGraphAuthorizeEndpoint + "?client_id=" + ClientId + "&redirect_uri=" + HttpUtility.UrlEncode(RequestUri) + "&response_type=code")));
            }
        }
 public StreetTeamEndpoint(AccessTokenManagerBase tokenManager, UsersModel user)
 {
     _tokenManager = tokenManager;
     _user = user;
 }