OAuth認証方法を使用しているときに、URLから認証コードを取得できません。 GoogleはDjango Google APIクライアントエラー..認証後にユーザーのGoogleカレンダーにイベントを追加するアプリケーションを実装しようとしています
その末尾に付加コードとURLに私をリダイレクトし..I自分自身を認証し、アプリに私のカレンダーを管理する権限を与えた後、私は http://127.0.0.1/Main/addloanpremium/?code=4/2wi1hu0Gv8YZuKo79kc-kjCmw7qj0W2EyLYa3qzIe7w#にリダイレクトしていますので、私は正規表現で間違いを犯していと思います。.. URLからコードを抽出するにはどうすればいいですか?上記のURLは新しいタブで開き、urls.pyは同じフォームページを表示しますが、request.GET.get( 'コード ')それは任意の値に..
例外値を与えるものではありません:変換できません 『:
暗黙的私のviews.pyのように見えるをstrするNoneType』オブジェクトを
def addloanpremium(request):
if request.method == 'GET':
loan=Loan()
premium=Premium()
user=request.user
#form=loan_pre_form(request.POST)
if(request.GET.get('typelp')=='loan'):
loan.user=user
#premium.user=user
#lots of code here..all values from fields are stored into the db
if(request.GET.get("iscalendar")=="True"):
print(" \n \n entered iscalendar =true \n")
print(" \n \n entered calendar now trying to add event \n \n")
SCOPES = 'https://www.googleapis.com/auth/calendar'
flow=auth2client.client.flow_from_clientsecrets('C:/Users/ghw/Desktop/Expenze/Main/client_secrets.json',SCOPES,redirect_uri='http://127.0.0.1:8000/Main/addloanpremium/')
storage = oauth2client.file.Storage('credentials.dat')
credentials = storage.get()
if not credentials or credentials.invalid:
auth_uri = flow.step1_get_authorize_url()
print("\n value of auth uri is "+auth_uri+"\n")
webbrowser.open(auth_uri)
auth_code = request.GET.get('code')
print("\n value of auth code is "+auth_code+"\n")
### I am getting the auth code wrong
credentials = flow.step2_exchange(auth_code)
storage.put(credentials)
http = httplib2.Http()
http = credentials.authorize(http)
CAL = build('calendar', 'v3', http=http)
.
.#lots of code here
.
return render(request,'Main/loan_pre_form.html',{})
私のメイン:urls.py:
url(r'^addloanpremium/$',views.addloanpremium,name='addloanpremium'),
私loan_pre_form.htmlは、任意のヘルプは高く評価されるだろう
<form action=" {% url 'Main:addloanpremium' %}" method="GET">
が含まれています。