Box'ConseAuthenticated'事件不是火

时间:2016-05-07 05:15:39

标签: c# asp.net box

一旦先前的刷新/访问令牌已经过期,我无法获得新的刷新/访问令牌,是否有办法使用sdk执行此操作,因为现在我再次转到https://box-token-generator.herokuapp.com/重新启动 - 创建刷新/访问令牌。这是代码示例

        var boxConfig = new BoxConfig(clientId, clientSecret, uriRedirect);
        OAuthSession oAuthSession = new OAuthSession(accessToken, refreshToken, expiresIn, tokenType);
        BoxClient boxClient = new BoxClient(boxConfig);
        boxClient.Auth.SessionAuthenticated += Auth_SessionAuthenticated;
        boxClient.Auth.SessionInvalidated += Auth_SessionInvalidated;

        boxClient = new BoxClient(boxConfig, oAuthSession);

1 个答案:

答案 0 :(得分:0)

请使用以下

1>

using Microsoft.SharePoint.Client;
using System;    
using System.Collections.Generic;    
using System.Linq;    
using System.Web;    
using System.Web.Mvc;    

namespace MVCApp.Controllers    
{    
    public class EmployeeController : Controller    
    {    
        [SharePointContextFilter]    
        public ActionResult Index()    
        {    
            User spUser = null;    

            var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);    

            using (var clientContext = spContext.CreateUserClientContextForSPHost())    
            {    
                if (clientContext != null)    
                {    
                    spUser = clientContext.Web.CurrentUser;    

                    clientContext.Load(spUser, user => user.Title);    

                    clientContext.ExecuteQuery();    

                    ViewBag.UserName = spUser.Title;    
                }    
            }    

            return View();    
        }    

    }    
}

2: 另外请添加以下方法

client.Auth.SessionAuthenticated += new EventHandler  < SessionAuthenticatedEventArgs > (Auth_SessionAuthenticated);