Kavsha
2 min readApr 20, 2021

--

Access Datastore in GCP with Cypress:

When I am doing automation, I hit in to scenario that should update email address in datastore in order to receive the email.

To achieve this, I make the cypress to connect with datastore and update the values using datastore api.

Now, How to access Cypress with datastore? below are the steps.

You need the below details to call the datastore API.

  1. GCP Project client ID
  2. GCP Project client secret.
  3. refresh token.

How to Get GCP Project client details:

Simple, access your GCP Project Console, access your web application make sure your application is configured with the redirect urls

Download the credential json and save. From that note client Id and client secret.

Now it is the time to generate refresh token, we need refresh token to generate access token every time, only access token keeps changing but refresh token remains same until it is regenerated again.

Steps to generate refresh token.

Access Auth2.0 playground below https://developers.google.com/oauthplayground/

configure own client Id and client secret.

select the datastore from the list to get access. At the end of third step, it will show refresh token.

Now We have all details to generate access token and use that to hit the datastore. All done now you can use the below cypress command and pass the method, url and body to change the value in datastore.

--

--