试图连接到一个API并打开MySQL端口使其工作,但终端只是挂起

2024-10-03 21:27:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图通过zohocrm连接到zcrmsdkpythonapi

一开始我尝试连接时,API会告诉我MySQL数据库拒绝连接,无法连接到3306端口。错误如下:

  File "/Users/hgducharme/Programming/Environments/SentriForceEnvironment/lib/python3.7/site-packages/mysql/connector/network.py", line 512, in open_connection
    errno=2003, values=(self.get_address(), _strioerror(err)))
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on '127.0.0.1:3306' (61 Connection refused)

所以接下来我通过运行nc -l localhost 3306在本地主机上打开了3306端口

现在,当我发送连接到API的命令时,我的终端就挂起了

下面是我与API连接的python代码:

from zcrmsdk import ZCRMRestClient, ZohoOAuth

# Tell Zoho it's me
config = {
    'sandbox': 'False',
    'applicationLogFilePath': './log',
    'client_id': '1000.xxxxxxxxxxxxxxxx'
    'client_secret': 'e9xxxxxxxxxxxxxxxxxxxxxxxxx',
    'redirect_uri': 'http://localhost:8000/some_path',
    'accounts_url': 'https://accounts.zoho.com',
    'token_persistance_path': '.',
    'currentUserEmail': 'email@gmail.com'
}

# Get an access token
ZCRMRestClient.initialize(config)
oauthClient = ZohoOAuth.get_client_instance()
grantToken = "1000.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
oauthTokens = oauthClient.generate_access_token(grantToken)

Tags: path端口comclienttokenapiconfiglocalhost