2017-12-29 8 views
0

私はPythonとdjangoの初心者です。 Dropboxで動作するようにdjangoを設定しようとしても、エラーが発生する "BadRequestException 'オブジェクトに' get '属性がありません。ここに私のコードです。エラー 'BadRequestException'オブジェクトには属性 'get'がありません

def get_dropbox_auth_flow(web_app_session): 
    APP_KEY= '****' 
    APP_SECRET = '****' 
    redirect_uri = "http://localhost:8000/dropbox" 
    return DropboxOAuth2Flow(APP_KEY, APP_SECRET, redirect_uri, web_app_session, "dropbox-auth-csrf-token") 

# URL handler for /dropbox-auth-start 
def dropbox_auth_start(request): 
    authorize_url = get_dropbox_auth_flow(request.session).start() 
    return HttpResponseRedirect(authorize_url) 

# URL handler for /dropbox-auth-finish 
def dropbox_auth_finish(request): 
    try: 
     access_token, user_id, url_state = get_dropbox_auth_flow(request.session).finish(request.GET) 
     # oauth_result = get_dropbox_auth_flow(request.session).finish(request.query_params) 
    except oauth.BadRequestException as e: 
     return e 
    except oauth.BadStateException as e: 
     # Start the auth flow again. 
     return HttpResponseRedirect("http://localhost:8000/dropbox_auth_start") 
    except oauth.CsrfException as e: 
     return HttpResponseForbidden() 
    except oauth.NotApprovedException as e: 
     raise e 
    except oauth.ProviderException as e: 
     raise e 

私は、あなたは、raise eを他のすべての例外についてはドキュメントhere

追加トレースバックhere

+0

おそらく 'request.get()'を意味していましたか?これは関数呼び出しなので、括弧が必要です。 – pault

+1

あなたの質問に完全なトレースバックを含めてください。 – Galen

+0

@Galenは私の元の質問でトレースバックを追加しました –

答えて

0

を次のですが、BadRequestExceptionのために、あなたはそれを返す - それゆえ、エラーを。

これはすべて非常に奇妙なことです。それを再発生させるためにだけ例外をキャッチするポイントはありません。実際に対処したいもの、つまりBadStateExceptionとCsrfExceptionだけをキャッチする必要があります。他のブロックをすべて削除し、それらを上流に捕らえる必要があります。

関連する問題