Exemplo n.º 1
0
        public override OauthMemberData GetOauthMemberData(OauthRequest request)
        {
            var oauthmemberdata = GooglePlusApi.Get(request.AccessToken);

            if (string.IsNullOrEmpty(oauthmemberdata.OauthId))
            {
                throw new Exception("Unable to get profile information from Google.");
            }

            // Store refresh token for long term access
            //oauthmemberdata.AccessToken = GooglePlusApi.GetRefreshToken(request.Code);

            return oauthmemberdata;
        }
Exemplo n.º 2
0
        override public OauthMemberData GetOauthMemberData(OauthRequest request)
        {
            var oauthmemberdata = GooglePlusApi.Get(request.AccessToken);

            if (string.IsNullOrEmpty(oauthmemberdata.OauthId))
            {
                throw new Exception("Unable to get profile information from Google.");
            }

            // Store refresh token for long term access
            //oauthmemberdata.AccessToken = GooglePlusApi.GetRefreshToken(request.Code);

            return(oauthmemberdata);
        }
Exemplo n.º 3
0
        override public OauthMemberData GetOauthMemberData(OauthRequest request)
        {
            // Get Long Term Access Token
            string longtermaccesstoken = FacebookGraphApi.GetLongTermAccessToken(request.AccessToken, AppId, AppSecret);

            // Use Long Term Access Token to Get FBUser
            var oauthmemberdata = FacebookGraphApi.Get(longtermaccesstoken);

            if (string.IsNullOrEmpty(oauthmemberdata.OauthId) || string.IsNullOrEmpty(oauthmemberdata.Picture))
            {
                throw new Exception("Unable to get profile information from Facebook.");
            }

            return(oauthmemberdata);
        }
Exemplo n.º 4
0
        public override OauthMemberData GetOauthMemberData(OauthRequest request)
        {
            // Get Long Term Access Token
            string longtermaccesstoken = FacebookGraphApi.GetLongTermAccessToken(request.AccessToken, AppId, AppSecret);

            // Use Long Term Access Token to Get FBUser
            var oauthmemberdata = FacebookGraphApi.Get(longtermaccesstoken);

            if (string.IsNullOrEmpty(oauthmemberdata.OauthId) || string.IsNullOrEmpty(oauthmemberdata.Picture))
            {
                throw new Exception("Unable to get profile information from Facebook.");
            }

            return oauthmemberdata;
        }
Exemplo n.º 5
0
        public ActionResult Login(OauthRequest model, OauthProviderBase provider, string returnUrl)
        {
            try
            {
                var m = provider.Get(model);

                // Create/Update as needed
                OauthMemberRepository.Checkin(m);

                // Login
                System.Web.Security.FormsAuthentication.SetAuthCookie(m.Username, true);

                // Return
                return(Content(GetLocalUrl(returnUrl)));
            }
            catch (Exception ex)
            {
                return(Content("An error occurred. " + ex.Message + ex.StackTrace + ex.InnerException));
            }
        }
Exemplo n.º 6
0
 public ActionResult GoogleLogin(OauthRequest model, string returnUrl)
 {
     return(Login(model, new GooglePlus.GooglePlusProvider(), returnUrl));
 }
Exemplo n.º 7
0
 public ActionResult FacebookLogin(OauthRequest model, string returnUrl)
 {
     return(Login(model, new Facebook.FacebookProvider(), returnUrl));
 }