internal static TokenResponse CreateFromBrokerResponse(IDictionary <string, string> responseDictionary) { if (responseDictionary.ContainsKey(TokenResponseClaim.ErrorDescription)) { return(new TokenResponse { Error = responseDictionary[TokenResponseClaim.Error], ErrorDescription = responseDictionary[TokenResponseClaim.ErrorDescription] }); } return(new TokenResponse { Authority = responseDictionary.ContainsKey("authority") ? Authenticator.EnsureUrlEndsWithForwardSlash(EncodingHelper.UrlDecode(responseDictionary["authority"])) : null, AccessToken = responseDictionary["access_token"], RefreshToken = responseDictionary.ContainsKey("refresh_token") ? responseDictionary["refresh_token"] : null, IdTokenString = responseDictionary["id_token"], TokenType = "Bearer", CorrelationId = responseDictionary["correlation_id"], Resource = responseDictionary["resource"], ExpiresOn = long.Parse(responseDictionary["expires_on"].Split('.')[0], CultureInfo.CurrentCulture) }); }
protected override void UpdateBrokerParameters(IDictionary <string, string> parameters) { Uri uri = new Uri(this.authorizationResult.Code); string query = EncodingHelper.UrlDecode(uri.Query); Dictionary <string, string> kvps = EncodingHelper.ParseKeyValueList(query, '&', false, this.CallState); parameters["username"] = kvps["username"]; }
private AuthenticationResultEx ProcessBrokerResponse() { string[] keyValuePairs = brokerResponse.Query.Split('&'); IDictionary <string, string> responseDictionary = new Dictionary <string, string>(); foreach (string pair in keyValuePairs) { string[] keyValue = pair.Split('='); responseDictionary[keyValue[0]] = EncodingHelper.UrlDecode(keyValue[1]); if (responseDictionary[keyValue[0]].Equals("(null)") && keyValue[0].Equals("code")) { responseDictionary["error"] = "broker_error"; } } return(ResultFromBrokerResponse(responseDictionary)); }