コード例 #1
0
def sync_calender():
    # check storage for credentials
    store = Storage('GCal', frappe.session.user)
    # store = Storage('GCal', "makarand")
    credentials = store.get()

    if not credentials or credentials.invalid:
        url = get_oauth2_authorize_url('gcal')
        return {"url": url, "is_synced": False}
    else:
        from gcal.tasks import sync_google_calendar
        sync_google_calendar(credentials)
        return {"url": None, "is_synced": True}
コード例 #2
0
ファイル: sync_configuration.py プロジェクト: mbauskar/GCAL
def sync_calender():
	# check storage for credentials
	store = Storage('GCal', frappe.session.user)
	# store = Storage('GCal', "makarand")
	credentials = store.get()

	if not credentials or credentials.invalid:
		url = get_oauth2_authorize_url('gcal')
		return {
			"url":url,
			"is_synced": False
		}
	else:
		from gcal.tasks import sync_google_calendar
		sync_google_calendar(credentials)
		return {
			"url":None,
			"is_synced": True
		}
コード例 #3
0
def get_credentials(code):
    if code:
        params = get_oauth_keys('gcal')
        params.update({
            "scope": 'https://www.googleapis.com/auth/calendar',
            "redirect_uri": get_redirect_uri('gcal'),
            "params": {
                "approval_prompt": "force",
                'access_type': 'offline',
                "response_type": "code"
            }
        })
        flow = OAuth2WebServerFlow(**params)
        credentials = flow.step2_exchange(code)
        # Store Credentials in Keyring Storage
        store = Storage('GCal', frappe.session.user)
        store.put(credentials)
        # get events and create new doctype
        from gcal.tasks import sync_google_calendar
        sync_google_calendar(credentials)

    frappe.local.response["type"] = "redirect"
    frappe.local.response["location"] = "/desk#Calendar/Event"
コード例 #4
0
ファイル: sync_configuration.py プロジェクト: mbauskar/GCAL
def get_credentials(code):
	if code:
		params = get_oauth_keys('gcal')
		params.update({
			"scope": 'https://www.googleapis.com/auth/calendar',
			"redirect_uri": get_redirect_uri('gcal'),
			"params": {
				"approval_prompt":"force",
				'access_type': 'offline',
				"response_type": "code"
			}
		})
		flow = OAuth2WebServerFlow(**params)
		credentials = flow.step2_exchange(code)
		# Store Credentials in Keyring Storage
		store = Storage('GCal', frappe.session.user)
		store.put(credentials)
		# get events and create new doctype
		from gcal.tasks import sync_google_calendar
		sync_google_calendar(credentials)

	frappe.local.response["type"] = "redirect"
	frappe.local.response["location"] = "/desk#Calendar/Event"