0

Hey friends. I want to open Gmail but with a particular account. My python script has a list of gmail accounts and i want the one to open in gmail which has been clicked/selected. I tried using the credentials in the URL but am not happy with that as I don't want to put the users password in the URL + it doesn't work :).

I'm using webbrowser.open(URL) to open gmail.

Solution?

2 Answers2

0

I have no clue if this would work, but it may be worth a shot.

You could try to spoof the browser and login via urllib and grab the cookie. Then you could programatically put the cookie in the browsers cookie directory and launch the browser to gmail.

It seems like it would work if you can get the browser+google to believe the cookie is a valid one, but it may be possible.

Wayne Werner
  • 49,299
  • 29
  • 200
  • 290
0

Is there any reason why you're not using IMAP to interact with the Gmail account?

import imaplib
M=imaplib.IMAP4_SSL('imap.gmail.com', 993)
M.login('myemailaddress@gmail.com','password')

# do things!

M.close()
M.logout()
Acorn
  • 49,061
  • 27
  • 133
  • 172
  • It's not clear what you're trying to do. Where is the script running? What is it triggered by? It it just supposed to open up Gmail in a browser and login so that a user can use it? Or are you trying to automatically interact with the Gmail account. If the latter is true then you want to use IMAP/SMTP. – Acorn Mar 21 '11 at 11:08