Map<String, String> oAuthParams = queryOAuthParams(idKey);
if (oAuthParams == null) {
return localizedMessages.getString("WidgetAPIImpl.0"); //$NON-NLS-1$
}
IOAuthToken oauthToken = persistenceManager.findOAuthToken(widgetInstance);
if (oauthToken == null) oauthToken = persistenceManager.newInstance(IOAuthToken.class);
oauthToken.setAccessToken(oAuthTokenBunch.get("access_token"));
oauthToken.setExpires(System.currentTimeMillis() + 1000 * Integer.parseInt(oAuthTokenBunch.get("expires_in")));
oauthToken.setClientId(oAuthParams.get("clientId"));
oauthToken.setAuthzUrl(oAuthParams.get("authzServer"));