Displaying logged in gmail on my site using Python

144 Views Asked by At

I'm trying to display mobile gmail on my website into a div using python, but the problem is that I can't bring the active logged in session like if I would open gmail in a new tab, only I can show the login screen of the mobile gmail. Is there a way to achive this using urllib2 and coookielib? Here is the code so far:

import webapp2
import jinja2
import os
import urllib2
import cookielib

class MainHandler(webapp2.RequestHandler):
def get(self):

    cj = cookielib.CookieJar()

    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

    response = opener.open("https://mail.google.com/mail/u/0/x/1dpiqa8pfqv8z-/?f=1")

    template_values = {
        'content_gmail': unicode(response.read(), encoding='utf-8')
    }

    template = jinja_environment.get_template('templates/index.html')
    self.response.out.write(template.render(template_values))

    app = webapp2.WSGIApplication([
        ('/', MainHandler)
    ], 
debug=True)
1

There are 1 best solutions below

7
On