Answer the question
In order to leave comments, you need to log in
How to make the Upwork API work?
Hello,
There was a need to obtain the necessary information from the Upwork account. Following the links, I stumbled upon the UPwork API https://developers.upwork.com/?lang=ruby#getting-s... Next, choosing the version I needed (Ruby language), downloaded and installed the necessary gems and tried to run the myapp example. rb, specifying in it the 'consumer_key' and 'consumer_secret' known to me. As a result of the script, I was sent to a link to authorize a new device, which was successful.
At this stage, problems arose.
1) After authorization of the new device, on the https://www.upwork.com/UserSettings/linked-accounts tab , it turned out that there was nothing there.
2) After enabling the debug parameter in the config of the source code, a number of exceptions appeared in the log:
#!/usr/bin/ruby
$:.unshift '../lib'
$LOAD_PATH << File.dirname(__FILE__)
require 'upwork/api'
require 'upwork/api/routers/auth'
require 'upwork/api/routers/mc'
require 'upwork/api/routers/reports/time'
require 'upwork/api/routers/freelancers/search'
require 'pry'
# initiate config
config = Upwork::Api::Config.new({
'consumer_key' => '98993*****',
'consumer_secret' => 'daddf*****',
#'access_token' => 'cb0d5******',# assign if known
#'access_secret' => '27538*******',# assign if known
'debug' => true #false
})
# setup client
client = Upwork::Api::Client.new(config)
# run authorization in case we haven't done it yet
# and do not have an access token-secret pair
if !config.access_token and !config.access_secret
authz_url = client.get_authorization_url
puts "Visit the authorization url and provide oauth_verifier for further authorization"
puts authz_url
verifier = gets.strip
puts verifier
@token = client.get_access_token(verifier)
# store access token data in safe place!
end
# get my auth data
auth = Upwork::Api::Routers::Auth.new(client)
info = auth.get_user_info
$ ruby myapp.rb
Exception `OpenSSL::SSL::SSLErrorWaitReadable' at C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/openssl/buffering.rb:182 - read would block
> initializing client
> requesting autorization token
> got request token pair
<< dump-begin >>
#<OAuth::RequestToken:0x3097350 @token="****", @secret="****", @consumer=#<OAuth::Consumer:0x302a240 @key="****", @secret="****", @options={:signature_method=>nil, :request_token_path=>"/api/auth/v1/oauth/token/request", :authorize_path=>"/services/api/auth", :access_token_path=>"/api/auth/v1/oauth/token/access", :proxy=>nil, :scheme=>:header, :http_method=>:post, :oauth_version=>"1.0", :site=>"https://www.upwork.com"}, @http_method=:post, @http=#<Net::HTTP www.upwork.com:443 open=false>>, @params={:oauth_callback_confirmed=>"true", "oauth_callback_confirmed"=>"true", :oauth_token=>"****", "oauth_token"=>"****", :oauth_token_secret=>"****", "oauth_token_secret"=>"****"}>
<< dump-end >>
> building authorization url, which is
<< dump-begin >>
"https://www.upwork.com/services/api/auth?oauth_token=****"
Exception `OpenSSL::SSL::SSLErrorWaitReadable' at C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/openssl/buffering.rb:182 - read would block
Exception `OAuth::Unauthorized' at C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/oauth-0.5.1/lib/oauth/consumer.rb:217 - 401 Unauthorized
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/oauth-0.5.1/lib/oauth/consumer.rb:217:in `token_request': 401 Unauthorized (OAuth::Unauthorized)
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/oauth-0.5.1/lib/oauth/tokens/request_token.rb:20:in `get_access_token'
from C:/RailsProject/ruby-upwork/lib/upwork/api/client.rb:67:in `get_access_token'
from myapp.rb:33:in `<main>'
<< dump-end >>
Visit the authorization url and provide oauth_verifier for further authorization
https://www.upwork.com/services/api/auth?oauth_token=****
> getting access token pair
Answer the question
In order to leave comments, you need to log in
If I understood everything correctly, then you just need to follow the link in the last paragraph, and then try to run a different script.
so you have everything written in a mistake, if you can’t translate it yourself, go to google translate
It seems to me that your problem is not with Upwork, but with reading data via the https protocol. Try to read any https site and save what you read.
The problem is solved by correct server configuration. x.z. like, but somehow I solved it a long time ago for another software platform, don't cut it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question