首页 > 解决方案 > Python 中正确的三足 OAuth 工作流程是什么(例如:ImmoScout API)?(如何获取request_token)

问题描述

我正在尝试为 python 中的数据科学项目访问 ImmoScout24 web api,但我有点卡在 3 腿身份验证过程中。我用谷歌搜索了这个问题,但它有点特别,所以也许有人可以帮助我。

我想实现以下描述的工作流程:https ://api.immobilienscout24.de/api-docs/authentication/three-legged/#callback-url

为了获得 request_token(身份验证过程中的第一步),我尝试了以下方法:

API 凭证存储在这两个变量中:

client_key

client_secret

Python 代码如下所示

immoscout_api = OAuth1Session(client_key,
                            client_secret=client_secret)  

request_token_url='http://rest.immobilienscout24.de/restapi/security/oauth/request_token'

fetch_response = immoscout_api.fetch_request_token(request_token_url)

我的 Jupyter Notebook 出现错误,如下所示:

TokenRequestDenied: Token request failed with code 403, response was '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>403 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Bad request.
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
<BR clear="all">
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: M_HHRf9VaNN9xFRqWlHWt2txfuIsBE5fe6siJACFUFjVWw20p91jLg==
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>'.

有人可以帮我获取请求令牌吗?

标签: pythonapirestoauth

解决方案


推荐阅读