Saar peer
Saar peer

Reputation: 847

Nimbus openid - can't parse Azure OIDC Metadata

When calling

Issuer issuer = new Issuer("https://login.microsoftonline.com/common");
OIDCProviderConfigurationRequest oidcProviderConfigurationRequest = new OIDCProviderConfigurationRequest(issuer);

HTTPRequest httpRequest = oidcProviderConfigurationRequest.toHTTPRequest();
HTTPResponse httpResponse = httpRequest.send();

OIDCProviderMetadata.parse(httpResponse.getContentAsJSONObject());

I get the following

Caused by: java.net.URISyntaxException: Illegal character in path at index 24: https://sts.windows.net/{tenantid}/
    at java.net.URI$Parser.fail(URI.java:2848)
    at java.net.URI$Parser.checkChars(URI.java:3021)
    at java.net.URI$Parser.parseHierarchical(URI.java:3105)
    at java.net.URI$Parser.parse(URI.java:3053)
    at java.net.URI.<init>(URI.java:588)
    at com.nimbusds.oauth2.sdk.util.JSONObjectUtils.getURI(JSONObjectUtils.java:527)    

How can i overcome this ?

Upvotes: 0

Views: 459

Answers (1)

Carl Zhao
Carl Zhao

Reputation: 9549

(Moving from Comments to Answer)

The error message is telling you where to look. Look at the 24th character of the path.You need to make sure that spaces, _, {} and other character cannot appear in the URL.

For how to solution the problem of common illegal characters in URL, there are general solutions, it is recommended to use URLEncoder.

Please see: here.

Upvotes: 0

Related Questions