// GET: HotmartConection public ActionResult Autenticar(string code) { string URL = $"https://api-sec-vlc.hotmart.com/security/oauth/token?grant_type=authorization_code&code={code}&client_id=cacc845e-c27e-4aab-ab5b-a8ea6a759f58&redirect_uri=http://localhost:53520/HotmartConection/Autenticar"; //Autorização do AuTh - Hotmart client.DefaultRequestHeaders.Add("Authorization", "Basic Y2FjYzg0NWUtYzI3ZS00YWFiLWFiNWItYThlYTZhNzU5ZjU4OmZmNWNkMWU1LWUwN2YtNDQ0NS05ZGQyLWU0MjM0OTc5ZWZiOA=="); HttpResponseMessage response = client.PostAsJsonAsync <HotmartCredenciais>(URL, hotmartCredenciais).Result; if (response.IsSuccessStatusCode) { hotmartCredenciais = response.Content.ReadAsAsync <HotmartCredenciais>().Result; WebServicesApi webServices = new WebServicesApi(); webServices = db.WebServicesApis.Find(2); webServices.TokenAcess = hotmartCredenciais.AccessToken; db.Entry(webServices).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(View(webServices)); } return(View()); }
// GET: api/AuthHotmart/code - Autenticação para receber AccessToken public string GetAccessToken([FromUri] string code, [FromBody] HotmartCredenciais hotmartCredenciacias) { //Buscando o Basic do Hotmart string basic = db.WebServicesApis.Find(2).Basic; String uri = $"https://api-sec-vlc.hotmart.com/security/oauth/token?grant_type=authorization_code&code={code}&client_id={client}&redirect_uri=http://localhost:53520/api/AuthHotmart/"; client.DefaultRequestHeaders.Add("Authorization", $"Basic {basic}"); response = client.PostAsJsonAsync <HotmartCredenciais>("www", hotmartCredenciacias).Result; hotmartCredenciacias = response.Content.ReadAsAsync <HotmartCredenciais>().Result; return("value"); }