public IHttpActionResult Get(string appId, string appSecret) { if (string.IsNullOrWhiteSpace(appId) || string.IsNullOrWhiteSpace(appSecret)) { return(BadRequest("Error: Parameter is incorrect.")); } // 進行驗證 string hashCode = _token.Validation(appId, appSecret); if (hashCode.Contains("Error")) { return(BadRequest("Error: Parameter is incorrect.")); } // TODO: Check Token From Redis / DB // POC Read from File #region POC Code - FileReader string fileName = "AccessToken.txt"; string folder = HttpContext.Current.Server.MapPath("~/App_Data/"); string fullPath = folder + fileName; System.IO.Directory.CreateDirectory(folder); if (System.IO.File.Exists(fullPath)) { string fileToken = System.IO.File.ReadAllText(fullPath); if (!string.IsNullOrWhiteSpace(fileToken)) { return(Ok(fileToken)); } } #endregion // 產生 Token string rfcToken = UrlBase64.ToUrlReplace(Crypto.Rfc2898(hashCode)); // TODO: Add Token to Redis / DB // POC write to File #region POC Code - FileWriter System.IO.File.WriteAllText(fullPath, rfcToken); #endregion return(Ok(rfcToken)); }