Example #1
0
class Oauth2Service():
    decorator = OAuth2Decorator(
        client_id=
        '616429551496-5pq095a8rujmih0l0alfrl8jgadqtaaj.apps.googleusercontent.com',
        client_secret='7kOx9i9yDJriYbJbpFvDaizI',
        scope='https://www.googleapis.com/auth/calendar')

    service = discovery.build('calendar', 'v3')
Example #2
0
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_user_stub()

        decorator = OAuth2Decorator(client_id='foo_client_id',
                                    client_secret='foo_client_secret',
                                    scope=['foo_scope', 'bar_scope'],
                                    user_agent='foo')

        self._finish_setup(decorator, user_mock=UserMock)
Example #3
0
    def test_kwargs_are_passed_to_underlying_flow(self):
        decorator = OAuth2Decorator(client_id='foo_client_id',
                                    client_secret='foo_client_secret',
                                    user_agent='foo_user_agent',
                                    scope=['foo_scope', 'bar_scope'],
                                    access_type='offline',
                                    approval_prompt='force',
                                    revoke_uri='dummy_revoke_uri')
        request_handler = MockRequestHandler()
        decorator._create_flow(request_handler)

        self.assertEqual('https://example.org/oauth2callback',
                         decorator.flow.redirect_uri)
        self.assertEqual('offline', decorator.flow.params['access_type'])
        self.assertEqual('force', decorator.flow.params['approval_prompt'])
        self.assertEqual('foo_user_agent', decorator.flow.user_agent)
        self.assertEqual('dummy_revoke_uri', decorator.flow.revoke_uri)
        self.assertEqual(None, decorator.flow.params.get('user_agent', None))
        self.assertEqual(decorator.flow, decorator._tls.flow)
Example #4
0
import os
import logging
from models import models
import datetime
import time
import base64
import json

from google.appengine.ext import ndb
from google.appengine.api import users, memcache, app_identity
from apiclient.discovery import build
from oauth2client.contrib.appengine import OAuth2Decorator

profileauthdecorator = OAuth2Decorator(
    client_id=
    '705607693138-7e0nkaictkp5u64vj71ngih6085pmr6e.apps.googleusercontent.com',
    client_secret='5_Z9T-7JruwFiDSaflfYo-I2',
    scope='https://www.googleapis.com/auth/plus.login')

file = open('public/svg/twitter.svg', 'r')
try:
    twitter_svg = file.read()
finally:
    file.close()

file = open('public/svg/google.svg', 'r')
try:
    google_svg = file.read()
finally:
    file.close()
Example #5
0
import webapp2
import jinja2
import os
import logging
import models
import datetime

from google.appengine.ext import ndb
from google.appengine.api import users
from apiclient.discovery import build
from oauth2client.contrib.appengine import OAuth2Decorator

profileauthdecorator = OAuth2Decorator(
            client_id='314326393426-6bvmm9sds571kgnnd3k886i1sjq7co82.apps.googleusercontent.com',
            client_secret='QgKCMayAA5t2C1nmBbeg-Itn',
            scope='https://www.googleapis.com/auth/plus.login')

jinja_environment = jinja2.Environment(
    loader=jinja2.FileSystemLoader(os.path.dirname(__file__)))

class _BaseHandler(webapp2.RequestHandler):
    def initialize(self, request, response):
        super(_BaseHandler, self).initialize(request, response)

        self.user = users.get_current_user()

        if self.user:
            self.template_values = {
                'user': self.user,
                'is_admin': users.is_current_user_admin(),
                'logout_url': users.create_logout_url('/')}          
Example #6
0
#import urllib
#import urllib2
import webapp2

from oauth2client.service_account import ServiceAccountCredentials
from oauth2client.contrib.appengine import OAuth2Decorator
from googleapiclient.discovery import build
import datetime
from httplib2 import Http

# Initialize Jinja Environment
env = jinja2.Environment(loader=jinja2.FileSystemLoader('templates'))

decorator = OAuth2Decorator(
    client_id=
    '270567588357-nnleha1dmgvgr7jatb1du51ruvqn4mou.apps.googleusercontent.com',
    client_secret='cAn4N7YIjckbjRaHWNqp1OEZ',
    scope='https://www.googleapis.com/auth/calendar')

service = build('calendar', 'v3')


class TestHandler(webapp2.RequestHandler):
    def get(self):
        helpers.createNewCal(self)


# Main Handler that either shows the login page, the create an account page, or the dashboard
class MainHandler(webapp2.RequestHandler):
    def get(self):
        # Get current google account that is signed in
Example #7
0
from apiclient.discovery import build
from google.appengine.ext import webapp
from oauth2client.contrib.appengine import OAuth2Decorator
from config import CLIENT_ID, CLIENT_SECRET

ipdb.set_trace()
decorator = OAuth2Decorator(client_id='your_client_id',
                            client_secret='your_client_secret',
                            scope='https://www.googleapis.com/auth/calendar')

service = build('calendar', 'v3')


class MainHandler(webapp.RequestHandler):
    @decorator.oauth_required
    def get(self):
        # Get the authorized Http object created by the decorator.
        http = decorator.http()
        # Call the service using the authorized Http object.
        request = service.events().list(calendarId='primary')
        response = request.execute(http=http)
from oauth2client.contrib.appengine import OAuth2Decorator


OAUTH_DECORATOR = OAuth2Decorator(
    client_id='405427916132-5973brd7egkdsptqdck52992lvspvv0s.apps.googleusercontent.com',
    client_secret='sBgVwvA6caPGsb4vJY9mwROM',
    scope=[
        'https://www.googleapis.com/auth/userinfo.email',
    ],
    callback_path='/oauth2callback'
)