本文介绍了无法与上班族联系以获取任何信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I try to use upwork api in flask to get some information, but it doesn't work. How could I get something from upwork with its 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"

When I call "print(request_token)" it prints "null:null"

推荐答案

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

  1. check the code in view.py: you redefine client with an access token/secret which doesn't exist (judging by what you describe). As a result, you get 404 for non-existing token-secret pair.

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

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

try to implement a simple request using the only python-upwork library and only after that move the code under the flask, to avoid any unexpected behavior in your code.

这篇关于无法与上班族联系以获取任何信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 17:16