Example #1
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 #2
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 #3
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 #4
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 #5
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 #6
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')