Skip to content

Bug: Issue with refresh token parsing #103

@rjcreathors

Description

@rjcreathors

Prerequisites

Describe the issue

We've been using this Kinde SDK for a while and it works ok - definitely better than the previous iteration of the library.

However, we have now tried to extend our implementation to use refresh token for auto-renewal of access tokens and we ran into an issue.

When adding the offline scope to the Kinde client, retrieving tokens throws the following error:

java.text.ParseException: Invalid serialized unsecured/JWS/JWE object: Missing second delimiter
	at com.nimbusds.jose.JOSEObject.split(JOSEObject.java:232)
	at com.nimbusds.jwt.SignedJWT.parse(SignedJWT.java:129)
	at com.kinde.token.BaseToken.<init>(BaseToken.java:19)
	at com.kinde.token.RefreshToken.<init>(RefreshToken.java:11)
	at com.kinde.token.RefreshToken.init(RefreshToken.java:15)
	at com.kinde.session.KindeClientCodeSessionImpl.retrieveTokens(KindeClientCodeSessionImpl.java:82)

Upon some closer inspection, it seems that the library is trying to treat refresh tokens the same way as ID and access tokens - as JWT.
However from the payload it looks like the refresh token is an opaque token, and thus cannot be serialized.

We confirmed this by forking the repository and doing some minor tweaks to it, which fixed the issue and allowed us to reach our original goal - automatically refreshing the access token.

You can see the simple changes here.

Of course, our "fix" is far from perfect, but it should give you an idea of what's going on/what's wrong.

Hopefully you can think of some better way.

Library URL

https://github.com/kinde-oss/kinde-java-sdk

Library version

2.0.1

Operating system(s)

Other Linux

Operating system version(s)

Linux Mint 22.1 Cinnamon

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions