OAuth 2 Automation and JDBC calls
Hi, I'm creating an OAuth 2 automation script to handle our login screen when calling an /api/jwt token retrieval. When getting the token, our login pages appear, for which I have added 4 pages of Automation to handle entering User Name, Password, etc.
Page 1: Enter User Name screen
Page 2: Enter Password screen
Page 3: Request security token via Email or Text
Page 4: Enter valid security code which was received via Email or Text, and press Next
Once I reach Page 4, I realized I had no way of getting the security code which our website sends me.
So I began to consider my options. I felt like a JDBC call would work great and I could get the security token directly from the database. When I tried creating JDBC calls within the OAuth Automation script profile, it began to throw all sorts of errors, not being able to import groovy.sql.Sql, seeing a Sql.newInstance call as ReferenceError: Can't find variable: Sql]
I thought maybe if I could call an outside Groovy script to return the value I might try that. So I created a script file which works, but attempting this type of code in the OAuth 2 automation screen fails.
MyDBServer = "<removed>"
MyUser = "<removed>"
MyDBName = "<removed>"
Mysql = Sql.newInstance('jdbc:sqlserver://' + MyDBServer + ':1433;databaseName='+MyDBName+';integratedSecurity=true','','','com.microsoft.sqlserver.jdbc.SQLServerDriver')
Mydata = Mysql.firstRow("SELECT MyCode FROM secured.MyAccessCodes AC JOIN secured.MyTable US ON AC.MyID = US.MyID Where US.UserName = '"+MyUser+"' and AC.ActiveFlag = 1")
log.info(Mydata)
Mysql.close()
Any suggestions? I'd like to be able to add the database call directly into Step 4 of the OAuth 2 automation script in order to enter the security code into the window.