コード例 #1
0
        public async Task<ActionResult> LoginCallback(string code)
        {
            var config = Dependencies.GetConfig(Request.Url);
            var auth = new OAuth(config);
            var oauthResponse = await auth.RequestToken(code);

            FormsAuthentication.SetAuthCookie("steve", false);

            // Save the token to Mongo
            var repo = new UserRepository();
            var user = await repo.GetUser("steve");

            if (user == null)
            {
                user = new UserInfo
                {
                    Username = "******",
                    InstagramAccessToken = oauthResponse.AccessToken
                };

                await repo.InsertUser(user);
            }
            else
            {
                var update = Builders<UserInfo>.Update
                    .Set(u => u.InstagramAccessToken, oauthResponse.AccessToken);

                await repo.Collection.UpdateOneAsync(u => u.Username == "steve", update);
            }

            Dependencies.InstagramAuthToken = oauthResponse.AccessToken;

            return RedirectToAction("index");
        }        
コード例 #2
0
ファイル: HomeController.cs プロジェクト: docstrum/ProxyMe
 public async Task<ActionResult> OAuth(string code)
 {
     var auth = new OAuth(config);
     var oauthResponse = await auth.RequestToken(code);
     Session.Add("FRED.AuthInfo", oauthResponse);
     return RedirectToAction("Index");
 }