I'm using Facebook provider for authentication in my Vapor 4 app. Everything works fine on localhost, but I get the following error for callback URL for the app deployed on Heroku: invalidValue("long_fb_code_here", Swift.EncodingError.Context(codingPath: [], debugDescription: "Top-level String encoded as string JSON fragment.", underlyingError: nil)). I've found out this happens when setting a session access token in FacebookRouter.swift:52. For some reason the encoder has troubles with encoding the received access token as a string in Sessions+Imperial.swift:62.
As I noted it works fine on localhost which is really strange and I have no clue why. 😅 I have everything set up fine on Facebook side. As a temporary workaround I forked this repo and replaced try session.setAccessToken(accessToken) with session.data["access_token"] = accessToken. That works fine. I really wonder why this is an issue only in the deployed app.
If it is relevant, I use fluent as storage for sessions.
I'm using Facebook provider for authentication in my Vapor 4 app. Everything works fine on localhost, but I get the following error for callback URL for the app deployed on Heroku:
invalidValue("long_fb_code_here", Swift.EncodingError.Context(codingPath: [], debugDescription: "Top-level String encoded as string JSON fragment.", underlyingError: nil))
. I've found out this happens when setting a session access token inFacebookRouter.swift:52
. For some reason the encoder has troubles with encoding the received access token as a string inSessions+Imperial.swift:62
.As I noted it works fine on localhost which is really strange and I have no clue why. 😅 I have everything set up fine on Facebook side. As a temporary workaround I forked this repo and replaced
try session.setAccessToken(accessToken)
withsession.data["access_token"] = accessToken
. That works fine. I really wonder why this is an issue only in the deployed app.If it is relevant, I use
fluent
as storage for sessions.