Skip to content
This repository has been archived by the owner on Dec 12, 2018. It is now read-only.

Call to com.stormpath.sdk.account.Account.getAccessTokens() throws exception #1298

Open
saibot94 opened this issue Feb 8, 2017 · 0 comments

Comments

@saibot94
Copy link

saibot94 commented Feb 8, 2017

In our company, we use Stormpath, and have been providing a logout feature in our services that does a call similar to the following:

     jwtAuthenticationResult.getAccount().getAccessTokens().forEach(accessToken -> {
        if (accessToken.getJwt().equals(authat))
          accessToken.delete();
      });

However, when getAccessTokens is called, sometimes this exception is thrown:

com.stormpath.sdk.lang.InstantiationException: Unable to instantiate instance with constructor [public com.stormpath.sdk.impl.oauth.DefaultAccessToken(com.stormpath.sdk.impl.ds.InternalDataStore,java.util.Map)]
	at com.stormpath.sdk.lang.Classes.instantiate(Classes.java:191) ~[com.stormpath.sdk-stormpath-sdk-api-1.0.RC9.2.jar:1.0.RC9.2]
	at com.stormpath.sdk.impl.ds.DefaultResourceFactory.instantiate(DefaultResourceFactory.java:65) ~[com.stormpath.sdk-stormpath-sdk-impl-1.0.RC9.2.jar:1.0.RC9.2]
	at com.stormpath.sdk.impl.ds.DefaultDataStore.instantiate(DefaultDataStore.java:182) ~[com.stormpath.sdk-stormpath-sdk-impl-1.0.RC9.2.jar:1.0.RC9.2]
	at com.stormpath.sdk.impl.resource.AbstractCollectionResource.toResource(AbstractCollectionResource.java:168) ~[com.stormpath.sdk-stormpath-sdk-impl-1.0.RC9.2.jar:1.0.RC9.2]
	at com.stormpath.sdk.impl.resource.AbstractCollectionResource.toResourceList(AbstractCollectionResource.java:160) ~[com.stormpath.sdk-stormpath-sdk-impl-1.0.RC9.2.jar:1.0.RC9.2]
	at com.stormpath.sdk.impl.resource.AbstractCollectionResource.getCurrentPage(AbstractCollectionResource.java:133) ~[com.stormpath.sdk-stormpath-sdk-impl-1.0.RC9.2.jar:1.0.RC9.2]
	at com.stormpath.sdk.impl.resource.AbstractCollectionResource$PaginatedIterator.<init>(AbstractCollectionResource.java:187) ~[com.stormpath.sdk-stormpath-sdk-impl-1.0.RC9.2.jar:1.0.RC9.2]
	at com.stormpath.sdk.impl.resource.AbstractCollectionResource$PaginatedIterator.<init>(AbstractCollectionResource.java:171) ~[com.stormpath.sdk-stormpath-sdk-impl-1.0.RC9.2.jar:1.0.RC9.2]
	at com.stormpath.sdk.impl.resource.AbstractCollectionResource.iterator(AbstractCollectionResource.java:151) ~[com.stormpath.sdk-stormpath-sdk-impl-1.0.RC9.2.jar:1.0.RC9.2]
	at java.lang.Iterable.forEach(Iterable.java:74) ~[?:1.8.0_60]

Looking more closely into the calls, DefaultAccessToken initialization fails with "io.jsonwebtoken.JwtException: JWT failed validation; it cannot be trusted."

I believe that something happens to the access token between the time at which the server sends it and when the sdk tries to parse it. Anyway, the getAccessTokens() call shouldn't fail, but rather return only the valid access tokens that can be retrieved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants