· 6 years ago · Nov 30, 2018, 08:38 AM
1define api_autherize {
2 comment("data")
3 then {
4 plugin command("HeopasCustom.dll", "Heopas Var Clear All")
5 plugin command("HeopasCustom.dll", "Heopas Var Set", "key", "bfecd5933baa6fca7ef4c9903c3f43f7", "Local")
6 plugin command("HeopasCustom.dll", "Heopas Var Set", "secret", "29bd26659900554b", "Local")
7 plugin command("HeopasCustom.dll", "Heopas Var Set", "signature_method", "HMAC-SHA1", "Local")
8 }
9 comment("generate signature")
10 then {
11 navigate("{#root}/oauth/index.html","Wait")
12 wait(1)
13 change dropdown(<id="method">,"POST")
14 type text(<url field>,"https://www.upwork.com/api/auth/v1/oauth/token/request","Standard")
15 type text(<id="consumer-key">,$plugin function("HeopasCustom.dll", "$Heopas Var Get", "key"),"Standard")
16 type text(<id="consumer-secret">,$plugin function("HeopasCustom.dll", "$Heopas Var Get", "secret"),"Standard")
17 wait(1)
18 click(<data-bind="click: refreshTimestamp">,"Left Click","No")
19 wait(1)
20 plugin command("HeopasCustom.dll", "Heopas Var Set", "signature", $scrape attribute(<id="signature">,"value"), "Local")
21 plugin command("HeopasCustom.dll", "Heopas Var Set", "nonce", $scrape attribute(<id="nonce">,"value"), "Local")
22 plugin command("HeopasCustom.dll", "Heopas Var Set", "timestamp", $scrape attribute(<id="timestamp">,"value"), "Local")
23 }
24 comment("get request token")
25 then {
26 set(#temp,$plugin function("HeopasCustom.dll", "$Heopas HTTP Post", $scrape attribute(<target="signed_request">,"href"), "", "", "", "", "", 10),"Local")
27 plugin command("HeopasCustom.dll", "Heopas Var Set", "oauth_token", $plugin function("HeopasCustom.dll", "$Heopas Get Before", $plugin function("HeopasCustom.dll", "$Heopas Get After", #temp, "oauth_token="), "&oauth_token_secret"), "Local")
28 plugin command("HeopasCustom.dll", "Heopas Var Set", "oauth_token_secret", $plugin function("HeopasCustom.dll", "$Heopas Get After", #temp, "oauth_token_secret="), "Local")
29 }
30 comment("authorize token by logging in")
31 navigate("https://www.upwork.com/services/api/auth?oauth_token={$plugin function("HeopasCustom.dll", "$Heopas Var Get", "oauth_token")}","Wait")
32 wait for element(<(tagname="p" AND innertext=w"*Your oauth_verifier=*")>,"","Appear")
33 comment("get verifier")
34 plugin command("HeopasCustom.dll", "Heopas Var Set", "verifier", $plugin function("HeopasCustom.dll", "$Heopas Get After", $scrape attribute(<(tagname="p" AND innertext=w"*Your oauth_verifier=*")>,"innertext"), "Your oauth_verifier="), "Local")
35 comment("get new nonce and timestamp")
36 then {
37 navigate("{#root}/oauth/index.html","Wait")
38 wait(1)
39 change dropdown(<id="method">,"POST")
40 type text(<url field>,"https://www.upwork.com/api/auth/v1/oauth/token/access","Standard")
41 type text(<id="consumer-key">,$plugin function("HeopasCustom.dll", "$Heopas Var Get", "key"),"Standard")
42 type text(<id="consumer-secret">,$plugin function("HeopasCustom.dll", "$Heopas Var Get", "secret"),"Standard")
43 wait(1)
44 click(<data-bind="click: refreshTimestamp">,"Left Click","No")
45 wait(1)
46 plugin command("HeopasCustom.dll", "Heopas Var Set", "signature2", $scrape attribute(<id="signature">,"value"), "Local")
47 plugin command("HeopasCustom.dll", "Heopas Var Set", "nonce2", $scrape attribute(<id="nonce">,"value"), "Local")
48 plugin command("HeopasCustom.dll", "Heopas Var Set", "timestamp2", $scrape attribute(<id="timestamp">,"value"), "Local")
49 }
50 comment("get access token")
51 set(#test,$plugin function("HeopasCustom.dll", "$Heopas HTTP Post", "https://www.upwork.com/api/auth/v1/oauth/token/access?oauth_token={$plugin function("HeopasCustom.dll", "$Heopas Var Get", "oauth_token")}&oauth_consumer_key={$plugin function("HeopasCustom.dll", "$Heopas Var Get", "key")}&oauth_signature={$plugin function("HeopasCustom.dll", "$Heopas Var Get", "signature2")}&oauth_nonce={$plugin function("HeopasCustom.dll", "$Heopas Var Get", "nonce2")}&oauth_timestamp={$plugin function("HeopasCustom.dll", "$Heopas Var Get", "timestamp2")}&oauth_verifier={$plugin function("HeopasCustom.dll", "$Heopas Var Get", "verifier")}&oauth_signature_method={$plugin function("HeopasCustom.dll", "$Heopas Var Get", "signature_method")}", "", "", "", "", "", 30),"Global")
52 load html(#test)
53 stop script
54 set(#temp,$plugin function("HeopasCustom.dll", "$Heopas HTTP Post", "https://www.upwork.com/api/auth/v1/oauth/token/access?oauth_token={#temp3}&oauth_consumer_key={#temp}&oauth_signature={#temp7}", "", "", "", "", "", 30),"Local")
55}