Authentication with manual actions

Retrieve OTP Code and make it available for your GDSL test manually. When you launch a measurement on a Test Bench device with the Greenspector CLI, you can receive a email or a SMS on your own device linked to your account. May be you have to use an authenticator to retrieve the OTP manually.

To transmit the OTP code manually to the GDSL test, you have two following options.

Use a disposable email with mailsac

We use the same mechanism as describe in the two parts : “Create and configure a mailsac account” and “Example with OTP” of the page Authentication with email but the difference is that you have to send manually an email containing the OTP you have to the mailsac email.

Use a public JSON File

Get the OTP and write it to a public json file on Internet that your GDSL test will read.

Before launching your GDSL test, you have to put a file available on internet via any drive you can use (for example google drive)

this file must be in the json format :

{ "value":"" }

Then when you have received your OTP code, add it on this same file

{ "value":"123456" }

Here is an example of a GDSL test reading the OTP code you have set in your json file. You have to adapt to your own context :

# this method checks your json file exists with an empty value before asking a new OTP code initOTPManual,https://myonlineotpfile.json # Log into your app, for example a login / password form with a submit button # you have to adapt to your own context setTextById,mylogin,com.myapp:id/loginEditText setTextById,mypassword,com.myapp:id/passwordEditText waitUntilTextBeforeClick,submit # At this time an OTP code should be sent by email or sms. # this method waits for a value to be available on the previous file during 10 minutes # When you have received your code, set the OTP code on the previous file waitAndStoreOTP # Select the edit text of your app where to put OTP Code # for example clickByText,OTP code # Then you can use this method to enter the OTP code in the edit text enterStoredOTP

How to add a json file on Internet containing an OTP Code

You can use any drive or system specific to your company. The key is to have an online json file that can be accessed through an unique URL and that you can modify at any time.

Here is an example with google drive :

  • Add a file like this otp.json on your google drive.

  • On the file, you can click on the ‘…' to select the action 'share’

  • Select ‘Anyone with the link can view’.

  • Then copy link and put it in another tab of your browser

  • You can get the FILEID which is between /d/ and /view

  • In the following link, replace FILEID with the unique file ID that you copied from above

    https://drive.google.com/uc?export=download&id=FILEID
  • Your final link should look similar to this

    https://drive.google.com/uc?export=download&id=14cLhFfCTAPWQfpSYE-nVwPROn90ppQuip
  • Test your link, it should download your otp.json file

  • You can now change the contents of the otp.json stored to your google drive

To do this right click on the file or click on '…' button and select Open with ‘Text Editor’. Accept the message to authorize Text Editor to modify your file. You can then edit the field value of your json and click on button ‘save to drive’ to save the file.

If you used the same file to read OTP code, you can have the following GDSL error :
"Error on line authInitManualJSONFileOTP,https://drive.google.com/uc?export=download&id=1AzN-6sC0oFr0EZb8-2k6bOUR8rIcbbbr0-W (line: 22). Cause: The test could not access the json file (HTTP error 403). If you use google drive, the access may be blocked by google. Please try to create and use another one"

If you have these error, please do not create a new file with the same name, you need to create a file with another name. This is a google protection.