4
votes

I'm trying to create and app that uses reddit's OAuth flow to authenticate the user and retrieve an access token that will be used by my app for further reddit api calls.

When they consume the api call '/login', the client to be redirected to reddit's OAuth page where they will login and and accept or decline. Then they will be redirected to the OAuth callback URL where NodeJS will fetch the token (or the error) and proceed.

What is the best way I can test this flow and obtain the access token in the tests so I can use it for further testing calls?

1

1 Answers

2
votes

The best way is to mock the authorization URL in your tests, just to make sure that the rest of your app works correctly.

If you do need a valid token, for some sort of system testing after that, you have to check if the provider supports other authorization grant types that do not require user interaction. Like for example client_credentials or password grant_type.