OSCHINA 使用 Github 登录的源码
2012-05-21 15:46:43 来源:WEB开发网核心提示:使用之前要加载Github的Provider类static {config = SocialAuthConfig.getDefault();try {config.load();//加载扩展的登录providerfor(String provider_name : Arrays.asList("github&
使用之前要加载Github的Provider类
static { config = SocialAuthConfig.getDefault(); try { config.load(); //加载扩展的登录provider for(String provider_name : Arrays.asList("github"/*, "qq", "weibo"*/)){ String className = config.getApplicationProperties().getProperty(provider_name); String consumer_key = config.getApplicationProperties().getProperty(provider_name+".consumer_key"); String consumer_secret = config.getApplicationProperties().getProperty(provider_name+".consumer_secret"); String custom_permissions = config.getApplicationProperties().getProperty(provider_name+".custom_permissions"); OAuthConfig c = new OAuthConfig(consumer_key, consumer_secret); if(custom_permissions != null) c.setCustomPermissions(custom_permissions); c.setProviderImplClass(Class.forName(className)); config.addProviderConfig(provider_name, c); } } catch (Exception e) { throw new RuntimeException(e); } }
更多精彩
赞助商链接