Master Mind
Master Mind

Reputation: 3084

Jersey : setting multiple object in response

I am using dropwizard with jersey/jackson and satellizer .

In the signup route by default the returned Object is a JWT token like this:

Response.status(Status.CREATED).entity(token).build() 

So i want to emmbed extra data in the response like the user id and other data.

How could i achieve this?

Thanks in advance

Upvotes: 1

Views: 155

Answers (1)

Gabriel Kohen
Gabriel Kohen

Reputation: 4286

I would use Jose4J for encoding the returned access_token as the JWT sent back to Satellizer. In the Angular App use jsjws or jwt-decode to decode your token. Then in your Angular application you handle it in the promise of the authenticate:

    $auth.authenticate('google',params).then(function(response) {
      $log.log('Authenticated!!!!!!!');
      var token = $auth.getToken();
      var userInfo= jwt_decode(token);
    });

Upvotes: 2

Related Questions