Oauth Python

296 views
Skip to first unread message

Louis Müller

unread,
May 9, 2020, 11:27:23 AM5/9/20
to immobilienscout24-development
Hallo Zusammen,

ich versuche gerade mich mit Python und Oauth zu identifizieren. Allerdings klappt das nicht so ganz. Ich habe hier in der Gruppe gesucht und habe nur nicht funktionierenden Code gefunden. Ein Ansatz war dieser hier:

from rauth import OAuth1Service
import webbrowser

immoscout = OAuth1Service(
    name='immoscout',
    consumer_key='XXX',
    consumer_secret='XXX',

request_token, request_token_secret = immoscout.get_request_token(
    method='GET',
    params={'oauth_callback''oob'})

ANSWER:
<common:messages xmlns:common="http://rest.immobilienscout24.de/schema/common/1.0"> <message> <messageCode>ERROR_BAD_REQUEST</messageCode> <message>Missing callback.</message> </message> </common:messages>

Hat jemand einen funktionierenden Code für mein Anliegen?
Vielen Dank schonmal.

Viele Grüße

____________________________________________________________________________________________________

Hello,
I'm trying do the Oauth-dance via Python, but it isn't working at the moment. I tried to find solutions in this group, but there is just code thats not working properly. One of the solutions you can see above. 
Does anybody have a working Python Oauth-Authentication or tell me, what in the code above is causing the problem?
Thank you very much in advance

Vincent Fritzsche

unread,
May 10, 2020, 9:56:34 AM5/10/20
to immobilienscou...@googlegroups.com
Hi Louis,

The following code was working for me:
import requests_oauthlib
aut = requests_oauthlib.OAuth1Session("YOUR_KEY",
                                      client_secret='YOUR_SECRET')
definedHeaders = {'Accept': 'application/json'}
url = "https://rest.immobilienscout24.de/restapi/api/search/v1.0/search/region?realestatetype="+str(propertyType)+"&geocodes=1276"
result = aut.get(url,headers=definedHeaders)
Hope that helps,
Vincent


--
Sie erhalten diese Nachricht, weil Sie in Google Groups E-Mails von der Gruppe "immobilienscout24-development" abonniert haben.
Wenn Sie sich von dieser Gruppe abmelden und keine E-Mails mehr von dieser Gruppe erhalten möchten, senden Sie eine E-Mail an immobilienscout24-de...@googlegroups.com.
Wenn Sie diese Diskussion im Web verfolgen möchten, rufen Sie https://groups.google.com/d/msgid/immobilienscout24-development/fc0aac77-e137-489d-b528-3f69960fbe63%40googlegroups.com auf.

Louis Müller

unread,
May 10, 2020, 4:00:08 PM5/10/20
to immobilienscout24-development
Hello Vincent,

thank you very much for your help. Unluckily the HTTP-error #403 (Forbidden) occurs. I think, I need to get a OAuth-key and -secret by authenticating with my Consumer-key and -secret via the OAuth dance (https://api.immobilienscout24.de/api-docs/authentication/two-legged/ ). Maybe your code works with existing OAuth-credentials, but I need to get them first. But maybe I'm on the wrong way here, am I?

Best greetings, Louis.
Wenn Sie sich von dieser Gruppe abmelden und keine E-Mails mehr von dieser Gruppe erhalten möchten, senden Sie eine E-Mail an immobilienscout24-development+unsub...@googlegroups.com.

Natapon Pantuwong

unread,
Oct 6, 2020, 10:26:03 AM10/6/20
to immobilienscout24-development

Hello Vincent,

I follow your code, but I got error as 'Invalid signature for signature method HMAC-SHA1'.
Do you have any suggestion about this?

Best wishes,
Natapon

Sinchan Roy

unread,
Oct 12, 2020, 6:01:19 AM10/12/20
to immobilienscout24-development
Hello Natapon / Louis, 

Is your credentials working in Immoscout24 Playground : 


Use your own consumer key and secret option and provide your credentials to check it. 

If it works well, below code snippet, works for me perfectly. 


----snip----

import requests_oauthlib
import xmltodict
import json

key = 'xxxxxxxx'
secret = 'yyyyyyy'

immo = requests_oauthlib.OAuth1Session(key, client_secret=secret)

params = {'realestatetype' : 'apartmentrent', 'geocoordinates' : '48.126631;11.547643;3'}
url = 'https://rest.immobilienscout24.de/restapi/api/search/v1.0/search/radius'
r = immo.get(url, params=params)

my_dict = xmltodict.parse(r.content)
data = json.loads(json.dumps(my_dict))

print(data)

----snip----


I use 2 legged authentication. I do have 3 legged authentication snippet as well if you want. 

Thank You.

Best,
Sinchan Roy

Natapon Pantuwong

unread,
Oct 12, 2020, 11:38:44 PM10/12/20
to immobilienscout24-development
Hi Roy,

Your code seems to work. I can success authorize to the api. However, I got result as 'No authorization for this operation'. 
Can you suggest how to get permission?

Best regards,

Or Barel

unread,
Oct 13, 2020, 2:28:49 AM10/13/20
to immobilienscout24-development
Hi Natapon,

In order to get additional permissions you should fill this form.

Best regards,
Or

Reply all
Reply to author
Forward
0 new messages