Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How connect proxy in steampy? #202

Closed
plusf2p opened this issue Feb 6, 2021 · 9 comments
Closed

How connect proxy in steampy? #202

plusf2p opened this issue Feb 6, 2021 · 9 comments

Comments

@plusf2p
Copy link

plusf2p commented Feb 6, 2021

No description provided.

@Requestedd
Copy link

I am also interested in this topic! As I can see, now the steam.py does not have the function of using a proxy. In addition, I do not yet know how to implement the usual use of a proxy, which is possible in the case of sending post and get requests in the steam.py function, which are just transitions between us and the final requests to steam.

/ Мне тоже интересна эта тема! Как я вижу , сейчас у steam.py нет функции использования прокси. Кроме того , я пока не знаю , как можно внедрить обычное использование прокси , которое возможно в случае отправки запросов post и get в функции steam.py , которые являются лишь переходниками между нами и конечными запросами к стиму.

@dustiwe
Copy link

dustiwe commented Feb 13, 2021

change it in the library

image

and before login
proxy123 = f'{proxyLog}:{proxyPass}@{proxyIp}' (if with authorization)
steam_client._session.proxies = {'https': str(proxy123)}
steam_client.login(login, password, 'bla_bla.json')

@Requestedd
Copy link

Let me ask you: is this option also suitable? (this is for private proxies)

steamguard_data = {
    "steamid": steamid,
    "shared_secret": shared_secret_key,
    "identity_secret": identity_secret_key
}
steamguard_data = json.dumps(steamguard_data)

steam_client = SteamClient(API_KEY)

steam_client._session.proxies.update({
    "http": "http://login:pass@ip",
    "https": "http://login:pass@ip"
})

change it in the library

image

and before login
proxy123 = f'{proxyLog}:{proxyPass}@{proxyIp}' (if with authorization)
steam_client._session.proxies = {'https': str(proxy123)}
steam_client.login(login, password, 'bla_bla.json')

@dustiwe
Copy link

dustiwe commented Feb 15, 2021

I don't now
try to run with working and non-working proxies

Let me ask you: is this option also suitable? (this is for private proxies)

steamguard_data = {
    "steamid": steamid,
    "shared_secret": shared_secret_key,
    "identity_secret": identity_secret_key
}
steamguard_data = json.dumps(steamguard_data)

steam_client = SteamClient(API_KEY)

steam_client._session.proxies.update({
    "http": "http://login:pass@ip",
    "https": "http://login:pass@ip"
})

change it in the library
image
and before login
proxy123 = f'{proxyLog}:{proxyPass}@{proxyIp}' (if with authorization)
steam_client._session.proxies = {'https': str(proxy123)}
steam_client.login(login, password, 'bla_bla.json')

@Requestedd
Copy link

Good afternoon, I want to raise this topic again. Is there any official method for connecting a proxy?

@bukson
Copy link
Owner

bukson commented Apr 15, 2023

Official not, If anyone want to add it I will gladly merge it

@makarworld
Copy link
Contributor

Official not, If anyone want to add it I will gladly merge it

I create a Pull Request #278

Changes:

  • add proxy support to all requests
  • add cookies arg to init (if user saved session and want continue with them)
  • add autologout arg to init (if user want to save cookies and use it again later)
  • edit login method, if user provide username, password and steam guard when initialize class, method should not request
    them
  • edit login method, if session is alive, skip login method

Example:

from steampy.client import SteamClient

client = SteamClient(
    api_key='XXXXX5FXXDDXXXXXABECXXB0C86XXXXX', 
    username='steam_login', 
    password='steam_password', 
    steam_guard='account.maFile',
    proxies={
        "http": "http://login:password@host:port",
        "https": "http://login:password@host:port",
    }, 
    autologout = False)

client.login()
print(client.is_session_alive())

Session Control:

Also i add option autologout in __init__ function for more session control.
When autologout is True, session will be ended with program end
When autologout is False, session will be not end and you may re-use cookies later

Now you can save session cookies and re-use it later.

import json
cookies = client._session.cookies.get_dict()
with open('steam_cookies.json', 'w', encoding='utf-8') as f:
    json.dump(f, cookies)

re-use example:

from steampy.client import SteamClient
import json

with open('steam_cookies.json', 'r', encoding='utf-8') as f:
    cookies = json.load(f)
    
client = SteamClient(
    api_key = ..., 
    username = ..., 
    password = ..., 
    steam_guard = ...,
    proxies = ...,
    cookies = cookies,
    autologout = False)
    
print(client.is_session_alive())

@bukson
Copy link
Owner

bukson commented Sep 14, 2023

Please rebase you commits onto newest steampy version and make 1 commit out of your changes so it is easier to review

@bukson
Copy link
Owner

bukson commented Sep 14, 2023

Merged

@bukson bukson closed this as completed Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants