@@ -84,20 +84,35 @@ sub get_oauth_client {
84
84
$lwp = LWP::UserAgent-> new();
85
85
$lwp -> agent(UPWORK_LIBRARY_USER_AGENT);
86
86
87
- $self -> {oauth_client } = Net::OAuth2::Profile::WebServer-> new(
88
- client_id => $self -> {config }{client_id },
89
- client_secret => $self -> {config }{client_secret },
90
- access_token => $self -> {config }{access_token },
91
- refresh_token => $self -> {config }{refresh_token },
92
- expires_in => $self -> {config }{expires_in },
93
- expires_at => $self -> {config }{expires_at },
94
- site => BASE_HOST,
95
- authorize_path => URI_AUTH,
96
- access_token_path => URI_ATOKEN,
97
- refresh_token_path => URI_ATOKEN,
98
- redirect_uri => $self -> {config }{redirect_uri },
99
- user_agent => $lwp
100
- );
87
+ if ($self -> {config }{grant_type } eq " client_credentials" ) {
88
+ $self -> {oauth_client } = Net::OAuth2::Profile::WebServer-> new(
89
+ client_id => $self -> {config }{client_id },
90
+ client_secret => $self -> {config }{client_secret },
91
+ grant_type => $self -> {config }{grant_type },
92
+ access_token => $self -> {config }{access_token },
93
+ expires_in => $self -> {config }{expires_in },
94
+ expires_at => $self -> {config }{expires_at },
95
+ site => BASE_HOST,
96
+ access_token_path => URI_ATOKEN,
97
+ redirect_uri => $self -> {config }{redirect_uri },
98
+ user_agent => $lwp
99
+ );
100
+ } else {
101
+ $self -> {oauth_client } = Net::OAuth2::Profile::WebServer-> new(
102
+ client_id => $self -> {config }{client_id },
103
+ client_secret => $self -> {config }{client_secret },
104
+ access_token => $self -> {config }{access_token },
105
+ refresh_token => $self -> {config }{refresh_token },
106
+ expires_in => $self -> {config }{expires_in },
107
+ expires_at => $self -> {config }{expires_at },
108
+ site => BASE_HOST,
109
+ authorize_path => URI_AUTH,
110
+ access_token_path => URI_ATOKEN,
111
+ refresh_token_path => URI_ATOKEN,
112
+ redirect_uri => $self -> {config }{redirect_uri },
113
+ user_agent => $lwp
114
+ );
115
+ }
101
116
}
102
117
103
118
=item get
0 commit comments