internal bool parseJasonDataStructure(JsonDataStrcuture JsonDataStrcuture, string clientSecret) { access_token = new AccessToken(); access_token.token = JsonDataStrcuture.AccessToken; refresh_token = JsonDataStrcuture.RefreshToken; expires_in = JsonDataStrcuture.ExpiresIn; //scope needs to be handled Dictionary <int, string> keys = new Dictionary <int, string>(); keys.Add(1, clientSecret); try { id_token = new JsonWebToken(JsonDataStrcuture.AuthenticationToken, keys); if (id_token != null) { return(true); } else { return(false); } } catch (Exception e) { Console.Write(e); return(false); } }
public virtual TokenResponse callTokenEndpoint(TokenRequest req) { JsonDataStrcuture JsonDataStrcuture = new JsonDataStrcuture(); string postContent = String.Format("client_id={0}&redirect_uri={1}&client_secret={2}&code={3}&grant_type=authorization_code", HttpUtility.UrlEncode(req.client_id), HttpUtility.UrlEncode(req.redirect_uri), HttpUtility.UrlEncode(client_secret), HttpUtility.UrlEncode(req.code), HttpUtility.UrlEncode(req.grant_type)); HttpWebResponse response = HTTP.HTTPComm.HttpReq(TokenEndpointUrl, postContent, "POST"); if (response != null) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(JsonDataStrcuture)); JsonDataStrcuture = serializer.ReadObject(response.GetResponseStream()) as JsonDataStrcuture; if (JsonDataStrcuture != null) { TokenResponse TokenResponse = new TokenResponse(); if (TokenResponse.parseJasonDataStructure(JsonDataStrcuture, client_secret)) { return(TokenResponse); } else { return(null); } } } return(null); }
internal bool parseJasonDataStructure(JsonDataStrcuture JsonDataStrcuture, string clientSecret) { access_token = new AccessToken(); access_token.token = JsonDataStrcuture.AccessToken; refresh_token = JsonDataStrcuture.RefreshToken; expires_in = JsonDataStrcuture.ExpiresIn; //scope needs to be handled Dictionary<int, string> keys = new Dictionary<int, string>(); keys.Add(1, clientSecret); try { id_token = new JsonWebToken(JsonDataStrcuture.AuthenticationToken, keys); if (id_token != null) return true; else return false; } catch (Exception e) { Console.Write(e); return false; } }
public virtual TokenResponse callTokenEndpoint(TokenRequest req) { JsonDataStrcuture JsonDataStrcuture = new JsonDataStrcuture(); string postContent = String.Format("client_id={0}&redirect_uri={1}&client_secret={2}&code={3}&grant_type=authorization_code", HttpUtility.UrlEncode(req.client_id), HttpUtility.UrlEncode(req.redirect_uri), HttpUtility.UrlEncode(client_secret), HttpUtility.UrlEncode(req.code), HttpUtility.UrlEncode(req.grant_type)); HttpWebResponse response = HTTP.HTTPComm.HttpReq(TokenEndpointUrl, postContent, "POST"); if (response != null) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(JsonDataStrcuture)); JsonDataStrcuture = serializer.ReadObject(response.GetResponseStream()) as JsonDataStrcuture; if (JsonDataStrcuture != null) { TokenResponse TokenResponse = new TokenResponse(); if (TokenResponse.parseJasonDataStructure(JsonDataStrcuture, client_secret)) { return TokenResponse; } else return null; } } return null; }