public static double getAuthToken(string authCode) { AuthenticationKeys auth = new AuthenticationKeys(); MapAccessCredentials outputData = new MapAccessCredentials(); try { HttpContext.Current.Session["userAuthData"] = null; string uri = "https://login.uber.com/oauth/v2/token?client_secret=" + auth.uberClientSecret + "&client_id=" + auth.uberClientId + "&grant_type=authorization_code&redirect_uri=http://localhost:63685/KzUber/booking.html&code=" + authCode; var webRequest = (HttpWebRequest)WebRequest.Create(uri); webRequest.Method = "POST"; var webResponse = (HttpWebResponse)webRequest.GetResponse(); if ((webResponse.StatusCode == HttpStatusCode.OK) && (webResponse.ContentLength > 0)) { var reader = new StreamReader(webResponse.GetResponseStream()); string s = reader.ReadToEnd(); outputData = JsonConvert.DeserializeObject <MapAccessCredentials>(s); AccessCredentials accessData = new AccessCredentials(outputData.last_authenticated, outputData.access_token, outputData.expires_in, outputData.token_type, outputData.scope, outputData.refresh_token); HttpContext.Current.Session["userAuthData"] = accessData; return(accessData.getExpiryTime()); } else { Console.WriteLine("Error"); return(-1); } } catch (Exception ex) { Console.WriteLine(ex.Message); return(0); } }