title: Keycloak - NullPointerException in codeToToken on token retreive
body: <p>I'm trying to run keycloak as the simplest OpenID server with the simplest app to authenticate users. </p>
  
  <p>My steps:</p>
  
  <ol>
  <li>I run keycloak insance <code>docker run -p 8080:8080 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin jboss/keycloak</code></li>
  <li>I log in into keycloak instance, create new client with id <code>swarm</code>, I set <code>Authorization Enabled</code> to true, I set Valid Redirect URIs to <code>http://myapp/test.php</code>, rest is default.</li>
  <li>On <code>http://myapp/test.php</code> I have just link to <code>http://localhost:8080/auth/realms/master/protocol/openid-connect/auth?client_id=swarm&amp;response_type=code&amp;scope=code&amp;redirect_url=http://myapp/test.php</code> which I click</li>
  <li>I'm redirected to keycloak page, where I log in as admin/admin and I'm redirected back to <code>http://myapp/test.php?session_state=c15d4d10-31a9-41d8-a8ba-9ea84d8fd4fa&amp;code=ey...FA</code> (I cut code, as it was long)</li>
  <li>I'm trying to exchange that code for a token with <code>curl</code> manually, by calling <code>curl -d "client_id=swarm" -d "grant_type=authorization_code" -d "client_secret=51d9de29-35f8-4692-bdfc-72f4c0a5b25f" -d "session_state=62f12f56-968b-4068-bbb5-95e5c9f1bc23" -d "code=eey...FA" http://localhost:8080/auth/realms/master/protocol/openid-connect/token</code></li>
  <li>I'm getting 500 Server error with no message.</li>
  </ol>
  
  <p>In Keycloak logs I'm getting <code>NullPointerException</code> when trying to get a token from openid with this logs:</p>
  
  <blockquote>
    <p>10:02:16,987 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (default task-14) Uncaught server error: java.lang.NullPointerException
        at > org.keycloak.protocol.oidc.endpoints.TokenEndpoint.codeToToken(TokenEndpoint.java:310)
        at > org.keycloak.protocol.oidc.endpoints.TokenEndpoint.processGrantRequest(TokenEndpoint.java:172)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)</p>
  </blockquote>
  
  <p>Not sure what I can do next. I'll be helpful for any help.</p>