Skip to content

Commit 5e4b38f

Browse files
committed
Remove instance variable but always retrieve currently set credentials.
1 parent 7b5622c commit 5e4b38f

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

oauth/src/main/java/ch/cyberduck/core/oauth/OAuth2AuthorizationService.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ public class OAuth2AuthorizationService {
7878
= new GsonFactory();
7979

8080
private final Host host;
81-
/**
82-
* Static long-lived credentials
83-
*/
84-
private final Credentials credentials;
8581
private final LoginCallback prompt;
8682

8783
private String clientid;
@@ -118,7 +114,6 @@ public OAuth2AuthorizationService(final HttpTransport transport, final Host host
118114
final LoginCallback prompt) {
119115
this.transport = transport;
120116
this.host = host;
121-
this.credentials = host.getCredentials();
122117
this.tokenServerUrl = tokenServerUrl;
123118
this.authorizationServerUrl = authorizationServerUrl;
124119
this.prompt = prompt;
@@ -167,6 +162,7 @@ public OAuthTokens validate(final OAuthTokens saved) throws BackgroundException
167162
*/
168163
public OAuthTokens save(final OAuthTokens tokens) throws AccessDeniedException {
169164
log.debug("Save new tokens {} for {}", tokens, host);
165+
final Credentials credentials = host.getCredentials();
170166
credentials.setOauth(tokens).setSaved(new LoginOptions().save);
171167
switch(flowType) {
172168
case PasswordGrant:
@@ -209,7 +205,7 @@ public OAuthTokens authorize() throws BackgroundException {
209205
response = this.authorizeWithCode(prompt);
210206
break;
211207
case PasswordGrant:
212-
response = this.authorizeWithPassword(credentials);
208+
response = this.authorizeWithPassword(host.getCredentials());
213209
break;
214210
default:
215211
throw new LoginCanceledException();

0 commit comments

Comments
 (0)