微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

授权请求中的Upwork api Oauth2.0 redirect_url错误

如何解决授权请求中的Upwork api Oauth2.0 redirect_url错误

  1. 我收到凭据并从 https://github.com/upwork/python-upwork-oauth2/tree/master/example 运行 myapp.py
  2. 我的代码看起来像
def get_desktop_client():
    config = upwork.Config(
        {
            "client_id": "MYCLIENTID","client_secret": "CLIENTSECRET","redirect_uri": "https://a.callback.url",}
    )
    
    # If token data already kNown and saved,you can reuse them
    # by adding 'token' parameter to the config
    # token = {'access_token': 'xxxxxxxxxxxxxxxxxx','expires_at': 1590479276.547947,'expires_in': '86400','refresh_token': 'xxxxxxxxxxxxxxxxxxxxxxxx','token_type': 'Bearer'}
    # config = upwork.Config({'client_id': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','client_secret': 'xxxxxxxxxxxxx','token': token})

    client = upwork.Client(config)

    try:
        config.token
    except AttributeError:
        authorization_url,state = client.get_authorization_url()
        # cover "state" flow if needed
        authz_code = input(
            "Please enter the full callback URL you get "
            "following this link:\n{0}\n\n> ".format(authorization_url)
        )
        print("Retrieving access and refresh tokens.... ")
        token = client.get_access_token(authz_code)
        # WARNING: the access token will be refreshed automatically for you
        # in case it's expired,i.e. expires_at < time(). Make sure you replace the
        # old token accordingly in your security storage. Call client.get_actual_config
        # periodically to sync-up the data
        pprint(token)
        print("OK")

    # For further use you can store ``token`` data somewhere

    return client


if __name__ == "__main__":
   
    client = get_desktop_client()

    try:
        print("My info")
        pprint(auth.Api(client).get_user_info())
        # pprint(search.Api(client).find({'q': 'PHP'}))
        # pprint(team.Api(client).add_activity('mytestcompany','mytestcompany',{'code': 'team-task-001','description': 'Description','all_in_company': '1'}))
        # pprint(time.Gds(client).get_by_freelancer_full('mnovozhilov',{'tq': quote('SELECT task,memo WHERE worked_on >= "2017-06-01" AND worked_on <= "2017-06-02"')}))
    except Exception as e:
        # print("Exception at %s %s" % (client.last_method,client.last_url))
        raise e
  1. After clicking this link,I'm redirected to login upwork account
  2. After logining,I see this error

为什么我错了?请告诉我如何修复它。我会很感激的

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。