I have a web app which uses Google OAuth2 for security. There are many API endpoints which I need to test through postman, but they require the user to authenticate using google.
When I access some API, say localhost:8080/user
, the web app redirects to google login page if the user is not authenticated, and sends results after authentication. Otherwise, if the user is already authenticated, it simply sends back the results. I can also use localhost:8080/login
to explicitly login the user(which is what the login button does on the homepage). This works fine for browsers, but it does not work in postman.
How do I do the same in Postman? Trying to access the API returns the google login page, but there is no way to provide credentials(username, password and OTP). Is there a way by which I could login using the localhost:8080/login
endpoint?
One can use the "get new access token" option that is shown when OAuth2 is selected as auth option.
Upon selecting this option, add the relevant details, same as that in your application. Clicking request token should now show a simple browser like a window, where the OAuth providers login page shall be shown.
Upon login, Postman saves the token, which can then be used for further requests.
I have created a blog post with little bit more details.