Hallo,
ich habe ein Problem mit meinen Proxy Einstellungen.
benutze einen Raspberry Pi 3 mit jessie light und Python3.
möchte eine Oauth2 authentification machen und muss durch den proxy der company.
proxyadresse,port, username und password etc. ist alles korrekt.
Was mache ich falsch ?
mein code(oauth.py)
PHP
import os
proxy = 'https://username:password@Proxyadresse:Port'
#proxies = {'https': 'https://username:password@Proxyadresse:Port/'} #funktioniert auch nicht
os.environ['http_proxy'] = proxy
os.environ['HTTP_PROXY'] = proxy
os.environ['https_proxy'] = proxy
os.environ['HTTPS_proxy'] = proxy
import requests
import json
from oauthlib.oauth2 import LegacyApplicationClient
from requests_oauthlib import OAuth2Session
#für oauth2 Variablen
username = 'mein_username@....com'
password = 'mein_passwort'
client_id = 'meine_client_id'
client_secret = 'mein_client_secret'
tenant_ID = 'meine_tenant_ID'
authorization_base_url = 'https://login.microsoftonline.com/----hier steht meine tenant_id-----/oauth2/authorize'
token_url = 'https://login.microsoftonline.com/----hier steht meine tenant_id-----/oauth2/token'
scope = ['https://outlook.office365.com/']
redirect_uri = "https://localhost"
oauth = OAuth2Session(client=LegacyApplicationClient(client_id=client_id))
token = oauth.fetch_token(redirect_uri,token_url,client_id=client_id,username=username,password=password,resource=scope)
print(token)
[/php]
der Error Code:
[code]Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/urllib3/connectionpool.py", line 594, in urlopen
self._prepare_proxy(conn)
File "/usr/local/lib/python3.4/dist-packages/urllib3/connectionpool.py", line 810, in _prepare_proxy
conn.connect()
File "/usr/local/lib/python3.4/dist-packages/urllib3/connection.py", line 294, in connect
self._tunnel()
File "/usr/lib/python3.4/http/client.py", line 822, in _tunnel
message.strip()))
OSError: Tunnel connection failed: 502 cannotconnect
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 362, in send
timeout=timeout
File "/usr/local/lib/python3.4/dist-packages/urllib3/connectionpool.py", line 649, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.4/dist-packages/urllib3/util/retry.py", line 376, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='localhost', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 502 cannotconnect',)))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "oauth.py", line 38, in <module>
token = oauth.fetch_token(redirect_uri,token_url,client_id=client_id,username=username,password=password,resource=scope)
File "/usr/local/lib/python3.4/dist-packages/requests_oauthlib/oauth2_session.py", line 221, in fetch_token
verify=verify, proxies=proxies)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 500, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/requests_oauthlib/oauth2_session.py", line 360, in request
headers=headers, data=data, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 457, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 569, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 413, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='localhost', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 502 cannotconnect',)))
Alles anzeigen