Is there any way in which I can generate access token to test oauth for logging in with gmail?
I have created a google app, and got the client and secret ids.
The best solution to this currently is to log in to a Google account, capture the Google cookies for this session, then use these same cookies to acquire an authorization code in your tests later. Each time the test runs, it can create an authorization code and exchange this for an access token. I've found these cookies can last 6 months or more.
I did the following to achieve this using Chrome:
https://accounts.google.com/o/oauth2/auth.... Copy this full URL.ACCOUNT_CHOOSER, APISID, CONSENT, GAPS, ...Now during your test, you can do an HTTP GET request to the URL you captured above, and in the request you should include the cookies you captured above. You should get a 302 response with code=... in the URL shown in the Location header.
Finally, in your test you can exchange this code for an access and refresh token using a POST to https://www.googleapis.com/oauth2/v4/token.
The Google OAuth playground doesn't help us here, since you still need some manual interaction to generate the authorization code (the playground is not 'automated').