Exemplo n.º 1
0
        void GetUserInfo()
        {
            // VERY IMPORTANT: We set the Authorizer to the OAuth2Authentication instance
            // we constructed with the new Google Sign In data above
            var plusService = new Google.OpenSource.ServicePlus()
            {
                RetryEnabled = true,
                Authorizer   = currentAuth // Assign our authorizer as the converted authorization we made
            };

            // Create a QueryPlus object to get the details of the user with the given user ID.
            // The special value "me" indicates the currently signed in user, but you could use
            // any other valid user ID. Returns a PlusPerson.
            var query = Google.OpenSource.QueryPlus.QueryForPeopleGetWithUserId("me");

            plusService.ExecuteQuery(query, (ticket, obj, error) => {
                // obj contains the query results, we must cast it to PlusPerson in order to get its information
                var person = obj as Google.OpenSource.PlusPerson;
                if (error != null)
                {
                    InvokeOnMainThread(() => new UIAlertView("Error", error.Description, null, "Ok", null).Show());
                }
                else
                {
                    InvokeOnMainThread(() => {
                        var section = Root[1];
                        section.Add(new StyledStringElement("Display Name", person.DisplayName, UITableViewCellStyle.Subtitle));
                        section.Add(new StyledStringElement("Nick Name", person.Nickname, UITableViewCellStyle.Subtitle));
                        section.Add(new StyledMultilineElement("About Me", person.AboutMe, UITableViewCellStyle.Subtitle));
                        section.Add(new StyledStringElement("Birthday", person.Birthday, UITableViewCellStyle.Subtitle));
                        ReloadData();
                    });
                }
            });
        }
        void GetUserInfo()
        {
            // VERY IMPORTANT: We set the Authorizer to the OAuth2Authentication instance
            // we constructed with the new Google Sign In data above
            var plusService = new Google.OpenSource.ServicePlus () {
                RetryEnabled = true,
                Authorizer = currentAuth // Assign our authorizer as the converted authorization we made
            };

            // Create a QueryPlus object to get the details of the user with the given user ID.
            // The special value "me" indicates the currently signed in user, but you could use
            // any other valid user ID. Returns a PlusPerson.
            var query = Google.OpenSource.QueryPlus.QueryForPeopleGetWithUserId ("me");
            plusService.ExecuteQuery (query, (ticket, obj, error) => {
                // obj contains the query results, we must cast it to PlusPerson in order to get its information
                var person = obj as Google.OpenSource.PlusPerson;
                if (error != null)
                    InvokeOnMainThread (() => new UIAlertView ("Error", error.Description, null, "Ok", null).Show ());
                else {
                    InvokeOnMainThread (() => {
                        var section = Root[1];
                        section.Add (new StyledStringElement ("Display Name", person.DisplayName, UITableViewCellStyle.Subtitle));
                        section.Add (new StyledStringElement ("Nick Name", person.Nickname, UITableViewCellStyle.Subtitle));
                        section.Add (new StyledMultilineElement ("About Me", person.AboutMe, UITableViewCellStyle.Subtitle));
                        section.Add (new StyledStringElement ("Birthday", person.Birthday, UITableViewCellStyle.Subtitle));
                        ReloadData ();
                    });
                }
            });
        }