public async Task <ActionResult <string> > GetJS() { var client = _clientFactory.CreateClient(); var values = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("resource", _ewei.PaResourceUri), new KeyValuePair <string, string>("client_id", _ewei.PaClientId), new KeyValuePair <string, string>("client_secret", _ewei.PaKey), new KeyValuePair <string, string>("grant_type", "client_credentials"), // expires_in // new KeyValuePair<string, string>("expires_in", (10 * 60 * 60).ToString()), }; var request = new HttpRequestMessage(HttpMethod.Post, _ewei.PaAuthority) { Headers = { { HttpRequestHeader.Accept.ToString(), "application/x-www-form-urlencoded" }, }, Content = new FormUrlEncodedContent(values) }; var response = await client.SendAsync(request); var streamResult = await response.Content.ReadAsStringAsync(); var result = JSON.AsObj <RefreshAuthenticateResult>(streamResult); var json = JSON.ToJson(new EWeiFront { AccessToken = result.AccessToken, PlatformUrl = _ewei.PlatformUrl }); var js = $@" var _platForm = {json}; "; return(new JavaScriptResult(js)); }