def connect_evernote(request): client = get_evernote_client() request_token = client.get_request_token(evernote_redirect_uri) if not request.user.extras: request.user.extras = {} request.user.extras['evernote'] = request_token request.user.save() return HttpResponseRedirect(client.get_authorize_url(request_token))
def callback_evernote(request): try: client = get_evernote_client() access_token = client.get_access_token( oauth_token=request.user.extras['evernote']['oauth_token'], oauth_token_secret=request.user.extras['evernote']['oauth_token_secret'], oauth_verifier=request.GET['oauth_verifier']) request.user.extras['evernote'] = access_token if 'enabled' not in request.user.extras: request.user.extras['enabled'] = [] request.user.extras['enabled'].append('evernote') request.user.save() return HttpResponseRedirect('/reader/#/settings/?success=true&extra=evernote') except KeyError: if 'enabled' in request.user.extras: request.user.extras['enabled'].remove('evernote') request.user.save() return HttpResponseRedirect('/reader/#/settings/?success=false&extra=evernote')
def callback_evernote(request): try: client = get_evernote_client() access_token = client.get_access_token( oauth_token=request.user.extras['evernote']['oauth_token'], oauth_token_secret=request.user.extras['evernote'] ['oauth_token_secret'], oauth_verifier=request.GET['oauth_verifier']) request.user.extras['evernote'] = access_token if 'enabled' not in request.user.extras: request.user.extras['enabled'] = [] request.user.extras['enabled'].append('evernote') request.user.save() return HttpResponseRedirect( '/reader/#/settings/?success=true&extra=evernote') except KeyError: if 'enabled' in request.user.extras: request.user.extras['enabled'].remove('evernote') request.user.save() return HttpResponseRedirect( '/reader/#/settings/?success=false&extra=evernote')