Пример #1
0
        protected override void InitializeForApplicationCall()
        {
            base.InitializeForApplicationCall();
            if ((ApplicationToken == null) || (ApplicationToken.ExpiryLocal < DateTime.Now))
            {
                ApplicationToken = Authorize(new ApplicationAuthorization { ApplicationKey = GetApiKey() });
            }

            WebClient.Headers.Add(ApplicationToken.TokenKeyName, ApplicationToken.TokenKey);
        }
Пример #2
0
 protected void InitializeForUserCall()
 {
     InitializeForApplicationCall();
     if ((UserToken == null) || (UserToken.ExpiryLocal < DateTime.Now))
     {
         UserToken = Authenticate(new UserAuthorization { UserName = GetUsername(), Password = GetPassword() }
                                     , ApplicationToken.TokenKeyName
                                     , ApplicationToken.TokenKey);
     }
 }
Пример #3
0
        private void InitialiseApiCaller(ApiToken applicationToken)
        {
            var applicationSecurityAttribute = new ApplicationSecurityAttribute();
            var actionContext = new System.Web.Http.Controllers.HttpActionContext();

            Request.Headers.Add(applicationToken.TokenKeyName, applicationToken.TokenKey);

            actionContext.ControllerContext = this.ControllerContext;
            applicationSecurityAttribute.OnActionExecuting(actionContext);
        }