final OAuth2Token accessToken = this.getToken(gadgetUri, serviceName, user, scope,
OAuth2Token.Type.ACCESS);
final OAuth2Token refreshToken = this.getToken(gadgetUri, serviceName, user, scope,
OAuth2Token.Type.REFRESH);
final BasicOAuth2Accessor newAccessor = new BasicOAuth2Accessor(gadgetUri, serviceName,
user, scope, client.isAllowModuleOverride(), this, this.globalRedirectUri,
this.authority, this.contextRoot);
newAccessor.setAccessToken(accessToken);
newAccessor.setAuthorizationUrl(client.getAuthorizationUrl());
newAccessor.setClientAuthenticationType(client.getClientAuthenticationType());
newAccessor.setAuthorizationHeader(client.isAuthorizationHeader());
newAccessor.setUrlParameter(client.isUrlParameter());
newAccessor.setClientId(client.getClientId());
newAccessor.setClientSecret(client.getClientSecret());
newAccessor.setGrantType(client.getGrantType());
newAccessor.setRedirectUri(client.getRedirectUri());
newAccessor.setRefreshToken(refreshToken);
newAccessor.setTokenUrl(client.getTokenUrl());
newAccessor.setType(client.getType());
newAccessor.setAllowedDomains(client.getAllowedDomains());
ret = newAccessor;
this.storeOAuth2Accessor(ret);
}
}