public BasicUserData ProcessAuthRequest(ProcessAuthenticationContext context)
        {
            var authorization =
                googleConsumer.ProcessUserAuthorization();

            if (authorization.AccessToken == null)
            {
                return null;
            }

            var graphRequest =
                WebRequest
                    .Create("https://www.googleapis.com/oauth2/v1/userinfo?access_token=" +
                            Uri.EscapeDataString(authorization.AccessToken));

            using (var response = graphRequest.GetResponse())
            using (var responseStream = response.GetResponseStream())
            using (var streamReader = new StreamReader(responseStream))
            {
                var json = streamReader.ReadToEnd();
                var jsonObject = JObject.Parse(json);

                return
                    new BasicUserData
                        {
                            UserId = jsonObject["id"].ToString(),
                            UserName = jsonObject["name"].ToString(),
                            PictureUrl = jsonObject["picture"].ToString()
                        };
            }
        }
Beispiel #2
0
        public BasicUserData ProcessAuthRequest(ProcessAuthenticationContext context)
        {
            var authorization =
                googleConsumer.ProcessUserAuthorization();

            if (authorization.AccessToken == null)
            {
                return(null);
            }

            var graphRequest =
                WebRequest
                .Create("https://www.googleapis.com/oauth2/v1/userinfo?access_token=" +
                        Uri.EscapeDataString(authorization.AccessToken));

            using (var response = graphRequest.GetResponse())
                using (var responseStream = response.GetResponseStream())
                    using (var streamReader = new StreamReader(responseStream))
                    {
                        var json       = streamReader.ReadToEnd();
                        var jsonObject = JObject.Parse(json);

                        return
                            (new BasicUserData
                        {
                            UserId = jsonObject["id"].ToString(),
                            UserName = jsonObject["name"].ToString(),
                            PictureUrl = jsonObject["picture"].ToString()
                        });
                    }
        }
        public BasicUserData ProcessAuthRequest(ProcessAuthenticationContext context)
        {
            var authorization =
                facebookConsumer.ProcessUserAuthorization();

            if (authorization.AccessToken == null)
            {
                return null;
            }

            var graphRequest =
                WebRequest
                    .Create("https://graph.facebook.com/me?access_token=" +
                            Uri.EscapeDataString(authorization.AccessToken));

            using (var response = graphRequest.GetResponse())
            using (var responseStream = response.GetResponseStream())
            using (var streamReader = new StreamReader(responseStream))
            {
                var json = streamReader.ReadToEnd();
                var jsonObject = JObject.Parse(json);

                return
                    new BasicUserData
                        {
                            UserId = jsonObject["id"].ToString(),
                            UserName = jsonObject["name"].ToString(),
                            PictureUrl = string.Format("http://graph.facebook.com/{0}/picture", jsonObject["id"])
                        };
            }
        }
        public BasicUserData ProcessAuthRequest(ProcessAuthenticationContext context)
        {
            string screenName;
            int userId;

            var consumer = new TwitterConsumer(context.SessionStorage);
            return consumer.TryFinishSignInWithTwitter(out screenName, out userId)
                ? new BasicUserData
                        {
                            UserId = userId.ToString(CultureInfo.InvariantCulture),
                            UserName = screenName,
                            PictureUrl = string.Format("http://api.twitter.com/1/users/profile_image/{0}.png", screenName)
                        }
                : null;
        }
Beispiel #5
0
        public BasicUserData ProcessAuthRequest(ProcessAuthenticationContext context)
        {
            string screenName;
            int    userId;

            var consumer = new TwitterConsumer(context.SessionStorage);

            return
                (consumer.TryFinishSignInWithTwitter(out screenName, out userId)
                    ? new BasicUserData
            {
                UserId = userId.ToString(CultureInfo.InvariantCulture),
                UserName = screenName,
                PictureUrl =
                    string.Format("http://api.twitter.com/1/users/profile_image/{0}.png", screenName)
            }
                    : null);
        }