exchangeExternalAccessToken error
# support
c
Running updates on a mobile app and suddenly getting error when using this method with an okta token exchange. Still works in existing app, so trying to track down what might be causing this. The backend code to get the okta token is still working and the code has not changed for token exchange. Error when calling
exchangeExternalAccessToken
-
Not a valid base64 encoded string length
Some additional context: This is in react-native medplum sdk versions 3.0.2 (It was at 3..1.5 as an update BUT I thought maybe that was what was causing the error so I rolled back and still got it, this version matches current prod) When I inspect the response from oauth2/token I see a 200 response and I see id, access and refresh tokens along with my project name and profile name that I would expect. But SDK is throwing error that is being caught in a try...catch. I was trying to update to Expo SDK 51 from 50, this means I was bumping versions of Expo related packages. Going to play around a bit with downgrading some of those to determine if anything in there might be fighting with base64 encoding as it relates to medplum sdk
Attempted on both iOS and Android to verify wasn't singular platform.
c
Hi @codejenn - ugh, sorry that you hit this. Unfortunately, there has been a lot of thrash in
react-native
and
expo
with regards to base64 encoding There is a small compatibility note in the docs here: https://github.com/medplum/medplum/tree/main/packages/expo-polyfills#expo-sdk-compatibility > Expo SDK Compatibility > It's recommended you use the latest Expo SDK (SDK 51 as of May 2024). > > However, this package should be compatible with Expo SDK 49+. > > Going forward, each version of this package will advertise the minimum compatible Expo SDK required which is subject to change based on the breaking changes of underlying Expo packages. Expo SDK 51 requires Medplum 3.1.5+ Expo SDK 50 and lower can be used with any Medplum 3.1.4- Also, consider running
npx expo install --check
to make sure expo agrees with deps
c
@cody , thank you SO MUCH for this update and response. The thrash in expo RN has always been fun for the many years I've been doing this. I'm sorry I missed that note, I did try to do a search in the docs. I'm already using Expo 51 in this new project but will update the medplum SDK again and run the check. I'll report back but confident that this will be resolved with that.
I guess interesting note on the other existing project while I think about it is that it was started as a bare RN app adding in expo modules, this is doing the opposite. The original project is on Expo 50.
Sadly this did not solve the problem. I noted I had separate base-64 dependency I had installed in our original app before the expo-pollyfills were available and I was doign more manually login and otken exchanges. I attempted to see if it would make a difference if I installed that, unfortunately not. Running both expo-doctor and install --check have positive results without errors. Any other ideas?
Here's a snippet of dependencies
c
hm, bummer. Still the same error?
exchangeExternalAccessToken - Not a valid base64 encoded string length
?
c
Yep, that is exactly where it throws the error
I made sure to eliminate all other calls surrounding it to verify. Obviously without it returning/grabbing the response properly then all other requests fail from there. I am going to spend a little time digging into the medplum code to see if I can finagle it at all. If I find anything I'll let you know
r
Closing the loop on this, the solution was upgrading to Medplum 3.1.6
151 Views