func GetRealToken(w http.ResponseWriter, r *http.Request) { if r.Method == "GET" { token = oauth.GetTokenForMachineAccount(bearerToken) log.Printf("Real token = %s\n", token) } else { w.WriteHeader(http.StatusMethodNotAllowed) } }
func connect(r *http.Request) { log.Printf("DMC-Agent Connected - currently connected = %v\n", status.GetState()) buf := make([]byte, 1500) n, _ := r.Body.Read(buf) var machine = MachineAccount{} json.Unmarshal(buf[0:n], &machine) bearerToken := oauth.GetBearerTokenForMachineAccount(machine) oauth.GetTokenForMachineAccount(bearerToken) }
func Token(w http.ResponseWriter, r *http.Request) { if r.Method == "GET" { key := []byte("12345678901234567890123456789012") r.ParseForm() token := r.FormValue("access_token") sId := r.FormValue("session_id") log.Printf("Token crypted - token - %s\n", token) log.Printf("Token crypted - session_id - %s\n", sId) sId = oauth.DecryptAesCBC(key, sId) log.Printf("Decrypted Session = %s\n", sId) tempToken = oauth.DecryptAesCBC(key, token) log.Printf("Decrypted Token = %s\n", tempToken) ma := getMachineAccount(tempToken, sId) machine = ma bearerToken = oauth.GetBearerTokenForMachineAccount(machine) token = oauth.GetTokenForMachineAccount(bearerToken) fmsRegisterDevice(token) //http.Redirect(w, r, "https://int-admin.wbx2.com/#/login", 302) } else { w.WriteHeader(http.StatusMethodNotAllowed) } }