To be able to run this code (search jobs from upwork.com):
#!/usr/bin/env python
import upwork
from upwork.routers.jobs import search
# https://developers.upwork.com/?lang=python#authentication_authorization-request
# https://www.upwork.com/developer/keys/apply
config = upwork.Config(
{
"client_id": <my_client_id>,
"client_secret": <my_client_secret>,
"redirect_uri": <my_redirect_uri>
}
)
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)
params = {'q': 'php', 'title': 'Web developer'}
search.Api(client).find(params)
I need to define a callback URL.
How do I implement it?
Anyone have a php or python script to do it?
How you fetch (client side) the returned values from the API from your callback (server side)? Or you need a web service on your localhost? I can't host a web service on my localhost, because I don't have the hand on the network to forward to my private IP
Looks like it's easier to scrape the site than using API :/ What do you think?
I think you can achieve this with change your
redirect_uriconfiguration with your actual callback URL. I'm not so familiar withphpbut how about implement the callback URL with flask?the minimalistic setup should be like
you can test it in your local machine by running the flask server, and after you got authorized, the Upwork client will be called your
redirect_uri(in here it could be navigated to thehttp://127.0.0.1:5000/callbackurl) and thecallback()method will be called.If you wanted to get the returned response from your callback URL, you can fetch it with
requestslibrary likeplease bear in mind, that you will need to modify this code based on your case and the structure of your own server-side endpoint and also the way you setup the Upwork configuration.