示例#1
0
        public static OauthMemberData Get(string accesstoken)
        {
            var url = string.Format("https://graph.facebook.com/me?access_token={0}",
                                    accesstoken);
            var r        = new CoopRelay.Tools.HttpRequest(url);
            var response = r.Send();
            var data     = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(response);

            // User
            var oauthmemberdata = new OauthMemberData
            {
                OauthId     = data["id"],
                AccessToken = accesstoken,
                FirstName   = data["first_name"],
                LastName    = data["last_name"]
            };

            // Picture
            url = string.Format("https://graph.facebook.com/me/picture?redirect=false&height=200&width=200&access_token={0}",
                                accesstoken);
            r        = new CoopRelay.Tools.HttpRequest(url);
            response = r.Send();
            data     = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(response);
            oauthmemberdata.Picture = data["data"]["url"];

            return(oauthmemberdata);
        }
        public static OauthMemberData Get(string accesstoken)
        {
            var url = string.Format("https://graph.facebook.com/me?access_token={0}",
                accesstoken);
            var r = new CoopRelay.Tools.HttpRequest(url);
            var response = r.Send();
            var data = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(response);

            // User
            var oauthmemberdata = new OauthMemberData
            {
                OauthId = data["id"],
                AccessToken = accesstoken,
                FirstName = data["first_name"],
                LastName = data["last_name"]
            };

            // Picture
            url = string.Format("https://graph.facebook.com/me/picture?redirect=false&height=200&width=200&access_token={0}",
                accesstoken);
            r = new CoopRelay.Tools.HttpRequest(url);
            response = r.Send();
            data = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(response);
            oauthmemberdata.Picture = data["data"]["url"];

            return oauthmemberdata;
        }
示例#3
0
        //public static string GetRefreshToken(string code)
        //{
        //    string url = "https://www.googleapis.com/oauth2/v3/token";
        //    var r = new CoopRelay.Tools.HttpRequest(url,CoopRelay.Tools.HttpRequest.HttpMethod.POST);
        //    r.Add("code", code);
        //    r.Add("client_id",ClientId);
        //    r.Add("client_secret", ClientSecret);
        //    r.Add("redirect_uri", "https://outofthecoop.com/googleprovider");
        //    r.Add("grant_type", "authorization_code");

        //    var response = r.Send();
        //    var data = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(response);

        //    return data["refresh_token"];
        //}

        //public static string GetAccessToken(string refresh_token)
        //{
        //    string url = "https://www.googleapis.com/oauth2/v3/token";
        //    var r = new CoopRelay.Tools.HttpRequest(url, CoopRelay.Tools.HttpRequest.HttpMethod.POST);
        //    r.Add("client_id", ClientId);
        //    r.Add("client_secret", ClientSecret);
        //    r.Add("refresh_token", refresh_token);
        //    r.Add("grant_type", "refresh_token");
        //    var response = r.Send();
        //    var data = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(response);
        //    return data["access_token"];
        //}

        public static OauthMemberData Get(string accesstoken)
        {
            var url = string.Format("https://www.googleapis.com/plus/v1/people/me?access_token={0}",
                                    accesstoken);
            var r        = new CoopRelay.Tools.HttpRequest(url);
            var response = r.Send();
            var data     = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(response);

            // OauthMemberData
            var oauthmemberdata = new OauthMemberData
            {
                OauthId     = data["id"],
                AccessToken = accesstoken,
                FirstName   = data["name"]["givenName"],
                LastName    = data["name"]["familyName"],
                Picture     = SetImageSize(data["image"]["url"].ToString())
            };

            return(oauthmemberdata);
        }
示例#4
0
        //public static string GetRefreshToken(string code)
        //{
        //    string url = "https://www.googleapis.com/oauth2/v3/token";
        //    var r = new CoopRelay.Tools.HttpRequest(url,CoopRelay.Tools.HttpRequest.HttpMethod.POST);
        //    r.Add("code", code);
        //    r.Add("client_id",ClientId);
        //    r.Add("client_secret", ClientSecret);
        //    r.Add("redirect_uri", "https://outofthecoop.com/googleprovider");
        //    r.Add("grant_type", "authorization_code");
        //    var response = r.Send();
        //    var data = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(response);
        //    return data["refresh_token"];
        //}
        //public static string GetAccessToken(string refresh_token)
        //{
        //    string url = "https://www.googleapis.com/oauth2/v3/token";
        //    var r = new CoopRelay.Tools.HttpRequest(url, CoopRelay.Tools.HttpRequest.HttpMethod.POST);
        //    r.Add("client_id", ClientId);
        //    r.Add("client_secret", ClientSecret);
        //    r.Add("refresh_token", refresh_token);
        //    r.Add("grant_type", "refresh_token");
        //    var response = r.Send();
        //    var data = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(response);
        //    return data["access_token"];
        //}
        public static OauthMemberData Get(string accesstoken)
        {
            var url = string.Format("https://www.googleapis.com/plus/v1/people/me?access_token={0}",
                accesstoken);
            var r = new CoopRelay.Tools.HttpRequest(url);
            var response = r.Send();
            var data = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(response);

            // OauthMemberData
            var oauthmemberdata = new OauthMemberData
            {
                OauthId = data["id"],
                AccessToken = accesstoken,
                FirstName = data["name"]["givenName"],
                LastName = data["name"]["familyName"],
                Picture = SetImageSize(data["image"]["url"].ToString())
            };

            return oauthmemberdata;
        }