Skip to content

Commit

Permalink
refs #4821 do not drop the refresh token when the access token is acq…
Browse files Browse the repository at this point in the history
…uired
  • Loading branch information
davidnich committed Oct 5, 2023
1 parent a043c05 commit 36c1521
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions doxygen/lang/900_release_notes.dox.tmpl
Expand Up @@ -9,6 +9,8 @@

@subsection qore_1_19_2_bug_fixes Bug Fixes in Qore
- <a href="../../modules/RestClient/html/index.html">RestClient</a>
- fixed a bug where the OAUth2 refresh token was sometimes dropped when an access token was acquired
(<a href="https://github.com/qorelanguage/qore/issues/4821">issue 4821</a>)
- fixed a bug returning the token URL
(<a href="https://github.com/qorelanguage/qore/issues/4809">issue 4809</a>)
- <a href="../../modules/SalesforceRestClient/html/index.html">SalesforceRestClient</a>
Expand Down
12 changes: 7 additions & 5 deletions qlib/RestClient.qm
Expand Up @@ -132,7 +132,10 @@ printf("%N\n", ans.body);

@section restclientrelnotes Release Notes


@subsection restclientv2_1_1 RestClient v2.1.1
- fixed a bug where the OAUth2 refresh token was sometimes dropped when an access token was acquired
(<a href="https://github.com/qorelanguage/qore/issues/4821">issue 4821</a>)
- fixed a bug returning the token URL
(<a href="https://github.com/qorelanguage/qore/issues/4809">issue 4809</a>)

Expand Down Expand Up @@ -674,7 +677,6 @@ RestClient rest({"url": "http://localhost:8001/rest"});
# otherwise we will run into compatibility problems with the fix
clearConnectionPath();
}

if (exists opts.oauth2_refresh_token) {
refresh_token = opts.oauth2_refresh_token;
}
Expand Down Expand Up @@ -1304,7 +1306,7 @@ hash<auto> ans = rest.doRequest("DELETE", "/orders/1");
if (info."response-code" == 401 && oauth2_grant_type && oauth2_auto_refresh
&& ((now_us() - token_timestamp) > MinimumTokenRefresh)) {
on_error {
rethrow ex.err, ex.desc, ex.arg;
rethrow;
};

if (refresh_token) {
Expand Down Expand Up @@ -1452,13 +1454,13 @@ hash<auto> ans = rest.doRequest("DELETE", "/orders/1");
*/
private *hash<auto> getUpdateOptionsAfterLogin(hash<auto> h) {
hash<auto> new_opts;
if (h.token_type != token_type) {
if (h.token_type && h.token_type != token_type) {
new_opts.token_type = h.token_type;
}
if (h.access_token != token) {
if (h.access_token && h.access_token != token) {
new_opts.token = h.access_token;
}
if (h.refresh_token != refresh_token) {
if (h.refresh_token && h.refresh_token != refresh_token) {
new_opts.oauth2_refresh_token = h.refresh_token;
}
return new_opts;
Expand Down

0 comments on commit 36c1521

Please sign in to comment.