Token not returned if I add scope to buildAuthorizeUrl


I’ve based my app from the spring security mvc example.
When I add .withScope to the buildAuthorizeUrl it returns a null token, If I remove withScope it works fine. Snipped below. Am I missing something.

String authorizeUrl = controller.buildAuthorizeUrl(req, redirectUri)
.withAudience(String.format(“https://%s/userinfo”, appConfig.getDomain()))
.withScope(“profile email”)

Thank you.

If I add it as a parameter instead it works. Well that was confusing.

.withParameter(“scope”, “openid profile email”)