无法连接上班以获得任何信息

时间:2019-05-07 10:20:16

标签: python-3.x flask upwork-api

我尝试在烧瓶中使用upwork api来获取一些信息,但是它不起作用。我怎么能通过其api从工作中得到一些东西?

文件app.py

import os
from flask import *
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy
from config import Configuration
from upwork import *
import upwork


# Create Flask app
app = Flask(__name__)
app.config.from_object(Configuration)
db = SQLAlchemy(app)
conn = db.engine
#os.environ['HTTPLIB_CA_CERTS_PATH'] = app.config.get('PATH_PEM')

# Create Migration db
migrate = Migrate(app, db, compare_type=True)
manager = Manager(app)
manager.add_command('db', MigrateCommand)

UP_PUBLIC_KEY = app.config.get('UP_PUBLIC_KEY')
UP_SECRET_KEY = app.config.get('UP_SECRET_KEY')
UP_ACCESS_TOKEN = app.config.get('UP_ACCESS_TOKEN')
UP_ACCEES_TOKEN_SECRET = app.config.get('UP_ACCEES_TOKEN_SECRET')

文件view.py:

from app import *


@app.route('/')
def get_from_api():
    client = upwork.Client(UP_PUBLIC_KEY, UP_SECRET_KEY)
    client = upwork.Client(UP_PUBLIC_KEY, UP_SECRET_KEY, oauth_access_token=UP_ACCESS_TOKEN,
                           oauth_access_token_secret=UP_ACCEES_TOKEN_SECRET)
    request_token = client.auth.get_request_token()
    print(request_token)
    pass

当我调用“ print(request_token)”时,它会显示“ null:null”

1 个答案:

答案 0 :(得分:0)

  1. 检查view.py中的代码:您使用不存在的访问令牌/秘密重新定义客户端(根据您所描述的内容)。结果,对于不存在的令牌-秘密对,您将得到404。

  2. 查看http://upwork.github.io/python-upwork/getting_started.html#simple-example

  3. 上的文档
  4. 尝试使用唯一的python-upwork库并仅在将代码移到烧瓶下之后才实现简单的请求,以避免代码中发生任何意外行为。