Open
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Fastify version
3.27.4
Plugin version
4.5.0
Node.js version
16.14.2
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
12.3.1
Description
While trying to implement the feature letting me refresh my Google access_token using the previously emitted refresh_token using getNewAccessTokenUsingRefreshToken()
method and when I try to get it back to the client, I receive an error stating we're trying to stringify a circular JSON object while we expect to have a OAuth2Token instance.
Steps to Reproduce
- create a simple fastify app
- add the fastify-oauth2 package
- setup google oauth credentials (I didn't test but based on the code I suppose it should be reproduced for any oauth option out there)
- add the following code to a new typescript file under the routes directory:
fastify.get("/auth/google/refresh", async (request, reply) => {
const refresh_token = (request.query as { refresh_token: string })
.refresh_token;
const response =
await fastify.googleOAuth2.getNewAccessTokenUsingRefreshToken(
refresh_token,
{}
);
reply.send(response);
});
- perform a simple call using any rest client on the route and note the error on the terminal running the server
Expected Behavior
I expect to receive a Oauth2Token instance (if the refresh token is obviously correct) that would have the following structure:
export interface OAuth2Token {
token_type: 'bearer';
access_token: string;
refresh_token?: string;
expires_in: number;
}
Metadata
Metadata
Assignees
Labels
No labels