oauth2 icon indicating copy to clipboard operation
oauth2 copied to clipboard

Allow serialization of Token.Extra data

Open element-of-surprise opened this issue 6 years ago • 1 comments

The problem: Serializing a Token object drops necessary data that is used in OIDC and maybe other Oauth2 extensions. This data is stored in Token.raw and accessible only via Token.Extra(). This means any serialization drops the extra data.

Proposed solution: Make token.Raw public. This prevents serialization from dropping important data.

Other solutions: If the author knows what fields they want, they can make a another object that contains the Token and extra fields. But you need to know what those are ahead of time. You then have to reinsert that data via the Token.WithExtra and get a new token. This seems less ideal.

Note: I'd be glad to do the work, but I may not be seeing the full picture for why only accessors currently exist. Someone may have a better solution. I wanted to get direction on how better to solve this before putting forth a pull request. Thanks!

element-of-surprise avatar Sep 18 '18 23:09 element-of-surprise

Has anyone found any workarounds for this? I've been trying to write some tests regarding edge cases we've found with an app that's been doing refreshes that seem to drop the oidc data causing id_token to be missing and get a keyerror from the library :/

trying to avoid having the testserver instance in the test at the moment

ShiftedMr avatar Jun 15 '21 19:06 ShiftedMr