private OAuthResponse ReadOAuthResponseFromJson(string json) { var jObject = JObject.Parse(json); var error = jObject.GetStringValue(_errorParameter); if (!string.IsNullOrEmpty(error)) { return(OAuthResponse.WithError(error, jObject.GetStringValue(_errorDescriptionParameter))); } return(OAuthResponse.WithToken(new OAuthAccessToken( jObject.GetStringValue(_accessTokenParatemeter), "bearer".Equals(jObject.GetStringValue(_tokenTypeParameter), StringComparison.OrdinalIgnoreCase) ? TokenType.Bearer : TokenType.Unknown, jObject.GetStringValue(_refreshTokenParameter), GetExpireDate(jObject.GetStringValue(_expiresInParameter))))); }
internal virtual OAuthResponse ReadOAuthResponseFromUrl(string url) { var parameters = ReadResponseParameter(url); if (parameters.ContainsKey(_errorParameter)) { return(OAuthResponse.WithError(parameters[_errorParameter], parameters.ContainsKey(_errorDescriptionParameter) ? parameters[_errorDescriptionParameter] : null )); } if (parameters.ContainsKey(_codeParameter)) { return(OAuthResponse.WithCode(parameters[_codeParameter])); } var tokenTypeValue = parameters.ContainsKey(_tokenTypeParameter) ? parameters[_tokenTypeParameter] : string.Empty; return(OAuthResponse.WithToken(new OAuthAccessToken( parameters[Definition.TokenResponseUrlParameter], "bearer".Equals(tokenTypeValue, StringComparison.OrdinalIgnoreCase) ? TokenType.Bearer : TokenType.Url, GetExpireDate(parameters.ContainsKey(Definition.ExpiresParameter) ? parameters[Definition.ExpiresParameter] : string.Empty) ))); }