Example #1
0
def get_oauth_url():
	key = db_util.get_key(label)
	client_id = key['client_id']
	redirect_uri = key['redirect_uri'] 
	scope = key['scope'] 
	response_type = 'code'
	return 'https://login.live.com/oauth20_authorize.srf?scope=%(scope)s&redirect_uri=%(redirect_uri)s&client_id=%(client_id)s&response_type=%(response_type)s' % locals()
Example #2
0
def get_oauth_url():
	key = db_util.get_key(label)
	client_id = key['client_id']
	redirect_uri = key['redirect_uri'] 
	scope = key['scope'] 
	response_type = 'code'
	return 'https://login.live.com/oauth20_authorize.srf?scope=%(scope)s&redirect_uri=%(redirect_uri)s&client_id=%(client_id)s&response_type=%(response_type)s' % locals()
Example #3
0
def get_oauth_url():
    key = db_util.get_key(label)
    client_id = key['client_id']
    state = key['state']
    response_type = 'code'
    return 'https://www.box.com/api/oauth2/authorize?client_id=%(client_id)s&response_type=%(response_type)s&state=%(state)s' % locals(
    )
Example #4
0
def get_oauth_url():
	key = db_util.get_key('dropbox')
	client_id = key['client_id']
	redirect_uri = key['redirect_uri'] 
	state = key['state'] 
	response_type = 'code'

	return 'https://www.dropbox.com/1/oauth2/authorize?state=%(state)s&redirect_uri=%(redirect_uri)s&client_id=%(client_id)s&response_type=%(response_type)s' % locals()
Example #5
0
def get_oauth_url():
	key = db_util.get_key(label)
	client_id = key['client_id']
	redirect_uri = key['redirect_uri'] 
	scope = key['scope']
	access_type = 'offline'
	response_type = 'code'
	return 'https://accounts.google.com/o/oauth2/auth?scope=%(scope)s&redirect_uri=%(redirect_uri)s&client_id=%(client_id)s&access_type=%(access_type)s&response_type=%(response_type)s' % locals()
Example #6
0
def get_oauth_url():
    key = db_util.get_key('dropbox')
    client_id = key['client_id']
    redirect_uri = key['redirect_uri']
    state = key['state']
    response_type = 'code'

    return 'https://www.dropbox.com/1/oauth2/authorize?state=%(state)s&redirect_uri=%(redirect_uri)s&client_id=%(client_id)s&response_type=%(response_type)s' % locals(
    )
Example #7
0
def refresh_token(email):
    key = db_util.get_key(label)
    url = 'https://accounts.google.com/o/oauth2/token'
    values = {
            'client_id' :key['client_id'] ,
            'client_secret' : key['client_secret'] ,
            'grant_type' : 'refresh_token' ,
            'refresh_token' : db_util.fetch_token(email,label,"refresh_token")
    }
    response = requests.post(url,data = values).json()
    db_util.save_token(label,'access_token',response['access_token'], email)
Example #8
0
def refresh_token(email):
	key = db_util.get_key(label)
	url = 'https://login.live.com/oauth20_token.srf'
	values = {
		'client_id' :key['client_id'] ,
		'redirect_uri' : key['redirect_uri'] ,
		'client_secret' : key['client_secret'] ,
		'grant_type' : 'refresh_token' ,
		'refresh_token' : db_util.fetch_token(email,label,'refresh_token')
	}
	response = requests.post(url,data = values).json()
	db_util.save_token(label,'access_token',response['access_token'], email)
	db_util.save_token(label,'refresh_token',response['refresh_token'], email)
Example #9
0
def refresh_token(email):
	key = db_util.get_key(label)
	url = 'https://login.live.com/oauth20_token.srf'
	values = {
		'client_id' :key['client_id'] ,
		'redirect_uri' : key['redirect_uri'] ,
		'client_secret' : key['client_secret'] ,
		'grant_type' : 'refresh_token' ,
		'refresh_token' : db_util.fetch_token(email,label,'refresh_token')
	}
	response = requests.post(url,data = values).json()
	db_util.save_token(label,'access_token',response['access_token'], email)
	db_util.save_token(label,'refresh_token',response['refresh_token'], email)
Example #10
0
def callback_dropbox():
	key = db_util.get_key('dropbox')
	url = "https://api.dropbox.com/1/oauth2/token"
	app_key = key['client_id'] 
	app_secret = key['client_secret']

	values = {
            'code':request.args.get('code'),
            'redirect_uri': key['redirect_uri'],
            'grant_type':'authorization_code'
    }

	response = requests.post(url,auth = (app_key,app_secret),data = values).json()
	db_util.save_token('dropbox',"access_token",response['access_token'],session['email'])
	return redirect('/transfer')
Example #11
0
def callback_box():
	key = db_util.get_key('box')
	url = "https://www.box.com/api/oauth2/token"

	values = {
            'code':request.args.get('code',None),
        	'client_id': key['client_id'] ,
        	'client_secret': key['client_secret'],	
            'grant_type':'authorization_code'
        }

	response = requests.post(url,data = values).json()

	db_util.save_token('box',"access_token",response['access_token'],session['email'])
	db_util.save_token('box',"refresh_token",response['refresh_token'],session['email'])
	return redirect('/transfer')
Example #12
0
def callback_dropbox():
    key = db_util.get_key('dropbox')
    url = "https://api.dropbox.com/1/oauth2/token"
    app_key = key['client_id']
    app_secret = key['client_secret']

    values = {
        'code': request.args.get('code'),
        'redirect_uri': key['redirect_uri'],
        'grant_type': 'authorization_code'
    }

    response = requests.post(url, auth=(app_key, app_secret),
                             data=values).json()
    db_util.save_token('dropbox', "access_token", response['access_token'],
                       session['email'])
    return redirect('/transfer')
Example #13
0
def callback_google():
	key = db_util.get_key('google_drive')
	url = "https://accounts.google.com/o/oauth2/token"

	values = {
            'code':request.args.get('code'),
            'client_id': key['client_id'] ,
            'client_secret': key['client_secret'],
            'redirect_uri': key['redirect_uri'],
            'grant_type':'authorization_code'
    }

	response = requests.post(url,data = values).json()
	db_util.save_token('google_drive',"access_token",response['access_token'],session['email'])
	if(response.get('refresh_token',None) != None):
		 db_util.save_token('google_drive',"refresh_token",response['refresh_token'],session['email'])
	return redirect('/transfer')
Example #14
0
def callback_skydrive():
	key = db_util.get_key('skydrive')
	url = 'https://login.live.com/oauth20_token.srf'

	values = {
		'client_id' :key['client_id'] ,
		'redirect_uri' : key['redirect_uri'] ,
		'client_secret' : key['client_secret'] ,
		'grant_type' : 'authorization_code' ,
		'code' :request.args.get('code','')
	}
	
	response = requests.post(url,data = values).json()

	db_util.save_token('skydrive',"access_token",response['access_token'],session['email'])
	db_util.save_token('skydrive',"refresh_token",response['refresh_token'],session['email'])
	return redirect('/transfer')
Example #15
0
def callback_box():
    key = db_util.get_key('box')
    url = "https://www.box.com/api/oauth2/token"

    values = {
        'code': request.args.get('code', None),
        'client_id': key['client_id'],
        'client_secret': key['client_secret'],
        'grant_type': 'authorization_code'
    }

    response = requests.post(url, data=values).json()

    db_util.save_token('box', "access_token", response['access_token'],
                       session['email'])
    db_util.save_token('box', "refresh_token", response['refresh_token'],
                       session['email'])
    return redirect('/transfer')
Example #16
0
def callback_google():
    key = db_util.get_key('google_drive')
    url = "https://accounts.google.com/o/oauth2/token"

    values = {
        'code': request.args.get('code'),
        'client_id': key['client_id'],
        'client_secret': key['client_secret'],
        'redirect_uri': key['redirect_uri'],
        'grant_type': 'authorization_code'
    }

    response = requests.post(url, data=values).json()
    db_util.save_token('google_drive', "access_token",
                       response['access_token'], session['email'])
    if (response.get('refresh_token', None) != None):
        db_util.save_token('google_drive', "refresh_token",
                           response['refresh_token'], session['email'])
    return redirect('/transfer')
Example #17
0
def callback_skydrive():
    key = db_util.get_key('skydrive')
    url = 'https://login.live.com/oauth20_token.srf'

    values = {
        'client_id': key['client_id'],
        'redirect_uri': key['redirect_uri'],
        'client_secret': key['client_secret'],
        'grant_type': 'authorization_code',
        'code': request.args.get('code', '')
    }

    response = requests.post(url, data=values).json()

    db_util.save_token('skydrive', "access_token", response['access_token'],
                       session['email'])
    db_util.save_token('skydrive', "refresh_token", response['refresh_token'],
                       session['email'])
    return redirect('/transfer')
Example #18
0
def get_oauth_url():
	key = db_util.get_key(label)
	client_id = key['client_id']
	state = key['state'] 
	response_type = 'code'
	return 'https://www.box.com/api/oauth2/authorize?client_id=%(client_id)s&response_type=%(response_type)s&state=%(state)s' % locals()