log.debug("All languages are imported");
}
public void loadInitialOAuthServers() throws Exception {
// Yandex
OAuthServer yandexServer = new OAuthServer();
yandexServer.setName("Yandex");
yandexServer.setIconUrl("http://yandex.st/morda-logo/i/favicon.ico");
yandexServer.setClientId("<put your client_id>");
yandexServer.setClientSecret("<put your client_secret>");
yandexServer.setEmailParamName("default_email");
yandexServer.setEnabled(false);
yandexServer.setLoginParamName("default_email");
yandexServer.setRequestInfoUrl("https://login.yandex.ru/info?format=json&oauth_token={$access_token}");
yandexServer.setRequestTokenUrl("https://oauth.yandex.ru/token");
yandexServer.setRequestKeyUrl("https://oauth.yandex.ru/authorize?response_type=code&client_id={$client_id}");
yandexServer.setRequestTokenAttributes("grant_type=authorization_code&code={$code}&client_id={$client_id}&client_secret={$client_secret}");
yandexServer.setRequestTokenMethod(RequestMethod.POST);
oauthDao.update(yandexServer, null);
// Google
OAuthServer googleServer = new OAuthServer();
googleServer.setName("Google");
googleServer.setIconUrl("https://www.google.ru/images/google_favicon_128.png");
googleServer.setEnabled(false);
googleServer.setClientId("<put your client_id>");
googleServer.setClientSecret("<put your client_secret>");
googleServer.setRequestKeyUrl("https://accounts.google.com/o/oauth2/auth?redirect_uri={$redirect_uri}&response_type=code&client_id={$client_id}"
+ "&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile");
googleServer.setRequestTokenUrl("https://accounts.google.com/o/oauth2/token");
googleServer.setRequestTokenMethod(RequestMethod.POST);
googleServer.setRequestTokenAttributes("code={$code}&client_id={$client_id}&client_secret={$client_secret}&redirect_uri={$redirect_uri}&grant_type=authorization_code");
googleServer.setRequestInfoUrl("https://www.googleapis.com/oauth2/v1/userinfo?access_token={$access_token}");
googleServer.setLoginParamName("email");
googleServer.setEmailParamName("email");
googleServer.setFirstnameParamName("given_name");
googleServer.setLastnameParamName("family_name");
oauthDao.update(googleServer, null);
// Facebook
OAuthServer facebookServer = new OAuthServer();
facebookServer.setName("Facebook");
facebookServer.setIconUrl("https://www.facebook.com/images/fb_icon_325x325.png");
facebookServer.setEnabled(false);
facebookServer.setClientId("<put your client_id>");
facebookServer.setClientSecret("<put your client_secret>");
facebookServer.setRequestKeyUrl("https://www.facebook.com/dialog/oauth?client_id={$client_id}&redirect_uri={$redirect_uri}&scope=email");
facebookServer.setRequestTokenUrl("https://graph.facebook.com/oauth/access_token");
facebookServer.setRequestTokenMethod(RequestMethod.POST);
facebookServer.setRequestTokenAttributes("client_id={$client_id}&redirect_uri={$redirect_uri}&client_secret={$client_secret}&code={$code}");
facebookServer.setRequestInfoUrl("https://graph.facebook.com/me?access_token={$access_token}&fields=username,first_name,last_name,email");
facebookServer.setLoginParamName("username");
facebookServer.setEmailParamName("email");
facebookServer.setFirstnameParamName("first_name");
facebookServer.setLastnameParamName("last_name");
oauthDao.update(facebookServer, null);
}