예제 #1
0
        static async Task <GooglePlusUser> GetUserInfo(Token token)
        {
            string     query    = "https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + token.AccessToken;
            HttpClient client   = new HttpClient();
            string     userJson = "";

            userJson = await client.GetStringAsync(query); // could also use GetStreamAsync and avoid conversion to Stream

            return(GooglePlusUser.JsonToGooglePlusUser(userJson));
        }
예제 #2
0
        /// <summary>
        /// Devuelve un perfil google plus con los datos de él
        /// </summary>
        /// <param name="code">es la url resultado que viene del login de google</param>
        /// <returns>null if acces is denied</returns>
        public static async Task <GooglePlusUser> GetProfileAsync(string code)
        {
            GooglePlusUser profile = null;
            Token          token;

            //consigo token valido
            token = await GetAccessToken(code);

            //uso el token para obtener los datos del usuario
            profile = await GetUserInfo(token);

            return(profile);
        }