def login():
	oauth_base.delete_file()
	config = __config()
	url = 'https://accounts.google.com/o/oauth2/auth?' + urllib.urlencode({
		'client_id': config['client_id'],
		'redirect_uri': 'urn:ietf:wg:oauth:2.0:oob',
		'response_type': 'code',
		'scope': ' '.join(config['scopes']),
		'approval_prompt': 'force',
		'access_type': 'offline'
	})
	print 'Browser:'
	print url
	print 'Code:'
	code = sys.stdin.readline().strip()
	content = http.req_json('POST', 'https://www.googleapis.com:443/oauth2/v3/token', urllib.urlencode({
		'code': code,
		'client_id': config['client_id'],
		'client_secret': config['client_secret'],
		'redirect_uri': 'urn:ietf:wg:oauth:2.0:oob',
		'grant_type': 'authorization_code'
	}), { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' })
	now = int(datetime.datetime.now().strftime("%s"))
	expires_in = content['expires_in']
	content['created'] = now
	content['expires'] = now + expires_in
	content['handler'] = 'installed'
	oauth_base.write_file(content)
	print 'Done'
dataset/ETHPy150Open murer/dsopz/dsopz/oauth_installed.py/login/original