Jump to content

Automate Gmail using 3rd party API


Jerri
 Share

Recommended Posts

Hi Experts,

We are using single sign on software to automate login for many applications and it also provides a set of API's which can be used to validate user password again. The below codings checks for some particular process, call API if the process is running and this API will prompt login screen from 3rd party tool and perform authentication.

I wanted to automate Gmail application and used with IEattach function but failed. could someone please help me on where it should be used and how to attach with that... it would be much appreciated if you could help on this.

; get the window handle of the Act! Login Window

$handle = WinGetHandle("Login","")

; hide the window

WinSetState(HWND($handle), "", @SW_HIDE)

;checking whether autoit script is already running

If ProcessExists('Gmail.exe') Then

;calling API

$auth=ObjCreate("OneSignAuth.OneSignAuth")

$user=ObjCreate("Onesign.Auth.CurrentOneSignUser")

;ready for a new authentication

$auth.reset()

$s = $auth.authenticate()

Else

MsgBox(0,"Application is not running")

EndIf

if ($s) then

; authentication was succesfull

$app_user=$auth.GetAppCredential("Gmail","Username") ; Get creds $app_pw=$auth.GetAppCredential("Gmail","Password")

WinActivate(HWND($Handle))

ControlSetText(HWND($handle),"","[iD: 10333]",$app_user)

ControlSetText(HWND($handle),"","[iD: 10334]",$app_pw)

; submit the form

ControlClick(HWND($handle),"","[iD: 1]")

Else

; cancel the dialog

WinActivate(HWND($Handle))

ControlClick(HWND($handle),"","[iD: 2]")

EndIf

Link to comment
Share on other sites

Not sure if this falls under a current forum rule of login scripts being banned.

But I don't know the software anyway.

_IEAttatch is used like so as only one example.

$oIE = _IEAttatch("google.co.uk")

Where "google.co.uk" is the title of the IE window, but can be also the handle of it.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

I agree with JohnOne, this may be indirectly in violation of forum policy. While it appears that your intent is NOT malicious in any way, the potential misuse of such scripts is a problem. For this reason the discussion of automated login proceedures is forbidden on this forum. Although not specifically stated, the automation of 3rd party software for this purpose is perhaps a borderline infringement. I'm saying this to make you aware. Please familiarise yourself with the rules.

People are very helpful on this forum and very willing to offer coding advice. Some policies may seem strict but there is always a good reason. I hope this clears up any misunderstanding you might have regarding this.

Edited by czardas
Link to comment
Share on other sites

Thanks for helping me with this. I already tested in the same way as John suggested but it did not work. We are using Imprivata which provides single sign on solution for all the applications and I am actually working with some web based internal application for my company. I mentioned gmail just for an instance.. I will make sure to avoid such post in future if the given justification is not genuine.

Thanks for your help.

Link to comment
Share on other sites

Thanks for the additional information - that helps a lot. Given the circumstances, I believe I understand your objectives. The best advice I can give is that you make an attempt to write the code yourself. When you find a function that doesn't seem to work as you expect, try to isolate the problem and someone will possibly have a solution. It's always helpful to post some code. Just avoid posting anything that infriges the rules. In this case your choice of topic title was somewhat of an unfortunate mistake. Live and learn, so they say. :)


Edit:

BTW the Imprivata website is so cool. I'm trying to figure out what code would make the layers move at different speeds like that when scrolling. Really nice! :D

Edited by czardas
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...