本文整理汇总了Java中org.scribe.builder.ServiceBuilder类的典型用法代码示例。如果您正苦于以下问题:Java ServiceBuilder类的具体用法?Java ServiceBuilder怎么用?Java ServiceBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServiceBuilder类属于org.scribe.builder包,在下文中一共展示了ServiceBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBitbucketOAuthScribeService
import org.scribe.builder.ServiceBuilder; //导入依赖的package包/类
private OAuthService createBitbucketOAuthScribeService(String callbackUrl)
{
Organization organizationInstance = organizationService.get(Integer.parseInt(organization), false);
ServiceBuilder sb = new ServiceBuilder().apiKey(organizationInstance.getCredential().getOauthKey())
.signatureType(SignatureType.Header).apiSecret(organizationInstance.getCredential().getOauthSecret())
.provider(new Bitbucket10aScribeApi(organizationInstance.getHostUrl(), httpClientProvider))
.debugStream(new DebugOutputStream(log));
if (!StringUtils.isBlank(callbackUrl))
{
sb.callback(callbackUrl);
}
return sb.build();
}
示例2: getUserInfoJSON
import org.scribe.builder.ServiceBuilder; //导入依赖的package包/类
private JSONObject getUserInfoJSON(String code, String callBackUrl) {
OAuthService service = new ServiceBuilder()
.provider(FacebookApi.class)
.apiKey(apiKey)
.apiSecret(apiSecret)
.callback(host + callBackUrl)
.scope("email")
.build();
Verifier verifier = new Verifier(code);
Token accessToken = service.getAccessToken(NULL_TOKEN, verifier);
OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
request.addOAuthParameter("scope", "email");
service.signRequest(accessToken, request);
Response response = request.send();
LOG.info("response body is " + response.getBody());
try {
JSONObject obj = new JSONObject(response.getBody());
obj.put("access_token", accessToken.getToken());
return obj;
} catch (JSONException e) {
return new JSONObject();
}
}
示例3: CasOAuthService
import org.scribe.builder.ServiceBuilder; //导入依赖的package包/类
@Inject
CasOAuthService(
PluginConfigFactory cfgFactory,
@PluginName String pluginName,
@CanonicalWebUrl Provider<String> urlProvider) {
PluginConfig cfg = cfgFactory.getFromGerritConfig(pluginName + CONFIG_SUFFIX);
rootUrl = cfg.getString(InitOAuth.ROOT_URL);
String canonicalWebUrl = CharMatcher.is('/').trimTrailingFrom(urlProvider.get()) + "/";
fixLegacyUserId = cfg.getBoolean(InitOAuth.FIX_LEGACY_USER_ID, false);
service =
new ServiceBuilder()
.provider(new CasApi(rootUrl))
.apiKey(cfg.getString(InitOAuth.CLIENT_ID))
.apiSecret(cfg.getString(InitOAuth.CLIENT_SECRET))
.callback(canonicalWebUrl + "oauth")
.build();
}
示例4: BitbucketOAuthService
import org.scribe.builder.ServiceBuilder; //导入依赖的package包/类
@Inject
BitbucketOAuthService(
PluginConfigFactory cfgFactory,
@PluginName String pluginName,
@CanonicalWebUrl Provider<String> urlProvider) {
PluginConfig cfg = cfgFactory.getFromGerritConfig(pluginName + CONFIG_SUFFIX);
String canonicalWebUrl = CharMatcher.is('/').trimTrailingFrom(urlProvider.get()) + "/";
fixLegacyUserId = cfg.getBoolean(InitOAuth.FIX_LEGACY_USER_ID, false);
service =
new ServiceBuilder()
.provider(BitbucketApi.class)
.apiKey(cfg.getString(InitOAuth.CLIENT_ID))
.apiSecret(cfg.getString(InitOAuth.CLIENT_SECRET))
.callback(canonicalWebUrl + "oauth")
.build();
}
示例5: GitLabOAuthService
import org.scribe.builder.ServiceBuilder; //导入依赖的package包/类
@Inject
GitLabOAuthService(
PluginConfigFactory cfgFactory,
@PluginName String pluginName,
@CanonicalWebUrl Provider<String> urlProvider) {
PluginConfig cfg = cfgFactory.getFromGerritConfig(pluginName + CONFIG_SUFFIX);
String canonicalWebUrl = CharMatcher.is('/').trimTrailingFrom(urlProvider.get()) + "/";
rootUrl = cfg.getString(InitOAuth.ROOT_URL);
service =
new ServiceBuilder()
.provider(new GitLabApi(rootUrl))
.apiKey(cfg.getString(InitOAuth.CLIENT_ID))
.apiSecret(cfg.getString(InitOAuth.CLIENT_SECRET))
.callback(canonicalWebUrl + "oauth")
.build();
}
示例6: DexOAuthService
import org.scribe.builder.ServiceBuilder; //导入依赖的package包/类
@Inject
DexOAuthService(
PluginConfigFactory cfgFactory,
@PluginName String pluginName,
@CanonicalWebUrl Provider<String> urlProvider) {
PluginConfig cfg = cfgFactory.getFromGerritConfig(pluginName + CONFIG_SUFFIX);
String canonicalWebUrl = CharMatcher.is('/').trimTrailingFrom(urlProvider.get()) + "/";
rootUrl = cfg.getString(InitOAuth.ROOT_URL);
domain = cfg.getString(InitOAuth.DOMAIN, null);
serviceName = cfg.getString(InitOAuth.SERVICE_NAME, "Dex OAuth2");
service =
new ServiceBuilder()
.provider(new DexApi(rootUrl))
.apiKey(cfg.getString(InitOAuth.CLIENT_ID))
.apiSecret(cfg.getString(InitOAuth.CLIENT_SECRET))
.scope("openid profile email offline_access")
.callback(canonicalWebUrl + "oauth")
.build();
}
示例7: FacebookOAuthService
import org.scribe.builder.ServiceBuilder; //导入依赖的package包/类
@Inject
FacebookOAuthService(
PluginConfigFactory cfgFactory,
@PluginName String pluginName,
@CanonicalWebUrl Provider<String> urlProvider) {
PluginConfig cfg = cfgFactory.getFromGerritConfig(pluginName + CONFIG_SUFFIX);
String canonicalWebUrl = CharMatcher.is('/').trimTrailingFrom(urlProvider.get()) + "/";
service =
new ServiceBuilder()
.provider(FacebookApi.class)
.apiKey(cfg.getString(InitOAuth.CLIENT_ID))
.apiSecret(cfg.getString(InitOAuth.CLIENT_SECRET))
.callback(canonicalWebUrl + "oauth")
.scope(SCOPE)
.build();
}
示例8: GitHubOAuthService
import org.scribe.builder.ServiceBuilder; //导入依赖的package包/类
@Inject
GitHubOAuthService(
PluginConfigFactory cfgFactory,
@PluginName String pluginName,
@CanonicalWebUrl Provider<String> urlProvider) {
PluginConfig cfg = cfgFactory.getFromGerritConfig(pluginName + CONFIG_SUFFIX);
String canonicalWebUrl = CharMatcher.is('/').trimTrailingFrom(urlProvider.get()) + "/";
fixLegacyUserId = cfg.getBoolean(InitOAuth.FIX_LEGACY_USER_ID, false);
service =
new ServiceBuilder()
.provider(GitHub2Api.class)
.apiKey(cfg.getString(InitOAuth.CLIENT_ID))
.apiSecret(cfg.getString(InitOAuth.CLIENT_SECRET))
.callback(canonicalWebUrl + "oauth")
.scope(SCOPE)
.build();
}
示例9: KeycloakOAuthService
import org.scribe.builder.ServiceBuilder; //导入依赖的package包/类
@Inject
KeycloakOAuthService(
PluginConfigFactory cfgFactory,
@PluginName String pluginName,
@CanonicalWebUrl Provider<String> urlProvider) {
PluginConfig cfg = cfgFactory.getFromGerritConfig(pluginName + CONFIG_SUFFIX);
String canonicalWebUrl = CharMatcher.is('/').trimTrailingFrom(urlProvider.get()) + "/";
String rootUrl = cfg.getString(InitOAuth.ROOT_URL);
String realm = cfg.getString(InitOAuth.REALM);
serviceName = cfg.getString(InitOAuth.SERVICE_NAME, "Keycloak OAuth2");
service =
new ServiceBuilder()
.provider(new KeycloakApi(rootUrl, realm))
.apiKey(cfg.getString(InitOAuth.CLIENT_ID))
.apiSecret(cfg.getString(InitOAuth.CLIENT_SECRET))
.scope("openid")
.callback(canonicalWebUrl + "oauth")
.build();
}
示例10: provideOAuthService
import org.scribe.builder.ServiceBuilder; //导入依赖的package包/类
@Singleton
@Provides
public OAuthService provideOAuthService() {
ServiceBuilder serviceBuilder = new ServiceBuilder()
.apiKey(BuildConfig.GEOCACHING_API_KEY)
.apiSecret(BuildConfig.GEOCACHING_API_SECRET)
.callback(AppConstants.OAUTH_CALLBACK_URL)
.debug();
if (BuildConfig.GEOCACHING_API_STAGING) {
serviceBuilder.provider(GeocachingOAuthProvider.Staging.class);
} else {
serviceBuilder.provider(GeocachingOAuthProvider.class);
}
return serviceBuilder.build();
}
示例11: getSwiftAccess
import org.scribe.builder.ServiceBuilder; //导入依赖的package包/类
public static SwiftAccess getSwiftAccess ()
{
final HasAuthenticationSettings authSettings = Configuration.INSTANCE.getAuthenticationSettings() ;
String apiKey = authSettings.getClientId() ;
String apiSecret = authSettings.getClientSecret() ;
HubicOAuth20ServiceImpl service = (HubicOAuth20ServiceImpl) new ServiceBuilder()
.provider(HubicApi.class).apiKey(apiKey).apiSecret(apiSecret)
//.scope("account.r,links.rw,usage.r,credentials.r").callback(HubicApi.CALLBACK_URL)
.scope(scope).callback(HubicApi.CALLBACK_URL)
.build();
Verifier verif = service.obtainVerifier();
if (verif == null)
return null ;
Token accessToken = service.getAccessToken(null, verif);
return getSwiftAccess (service, accessToken) ;
}
示例12: doRequestAuth
import org.scribe.builder.ServiceBuilder; //导入依赖的package包/类
private TwitterAuthDoneEvent doRequestAuth()
{
Token token = null;
String authUrl = null;
try
{
OAuthService service = new ServiceBuilder()
.provider( TwitterApi.SSL.class )
.callback( TwitterLoginActivity.TWITTER_CALLBACK_URL )
.apiKey( TwitterConfig.TWITTER_OAUTH_CONSUMER_KEY )
.apiSecret( TwitterConfig.TWITTER_OAUTH_CONSUMER_SECRET )
.build();
token = service.getRequestToken();
authUrl = service.getAuthorizationUrl( token );
}
catch ( OAuthConnectionException e )
{
Helper.debug( "Error while obtaining twitter request token : " + e.getMessage() );
}
boolean success = null != token;
return new TwitterAuthDoneEvent( success, token, null, authUrl, AuthType.REQUEST );
}
示例13: doAuth
import org.scribe.builder.ServiceBuilder; //导入依赖的package包/类
@Override
protected void doAuth( Intent intent )
{
final String code = intent.getStringExtra( SitesLoginHandler.VERIFIER_KEY );
Token accessToken = null;
String userName = null;
try
{
OAuthService service = new ServiceBuilder()
.provider( InstagramApi.class )
.callback( InstagramLoginActivity.CALLBACK_URL )
.apiKey( InstagramConfig.INSTAGRAM_CLIENT_ID )
.apiSecret( InstagramConfig.INSTAGRAM_CLIENT_SECRET )
.scope( InstagramConfig.INSTAGRAM_SCOPE )
.build();
accessToken = service.getAccessToken( null, new Verifier( code ) );
userName = Helper.extractInstagramUserName( accessToken.getRawResponse() );
}
catch ( Exception e )
{
Helper.debug( "Error while obtaining Instagram access token : " + e.getMessage() );
}
boolean success = null != accessToken;
// Subscriber : InstagramLoginHandler : onInstagramAuthDone()
HashtaggerApp.bus.post( new InstagramAuthDoneEvent( success, accessToken, userName ) );
}
示例14: getOAuthService
import org.scribe.builder.ServiceBuilder; //导入依赖的package包/类
public static OAuthService getOAuthService(HttpServletRequest request, ThemeDisplay themeDisplay)
throws SystemException {
OAuthService service = null;
String consumerKey = StringPool.BLANK;
String consumerSecret = StringPool.BLANK;
// Set up the Scribe OAuthService.
String cbUrl = PortalUtil.getCurrentCompleteURL(request);
Class<? extends EvernoteApi> providerClass =
(EVERNOTE_SERVICE == EvernoteService.PRODUCTION) ?
org.scribe.builder.api.EvernoteApi.class :
EvernoteApi.Sandbox.class;
// Get consumer key and consumer secret
consumerKey = EvernoteKeys.getConsumerKey(themeDisplay.getCompanyId());
consumerSecret = EvernoteKeys.getConsumerSecret(themeDisplay.getCompanyId());
service = new ServiceBuilder().provider(providerClass)
.apiKey(consumerKey).apiSecret(consumerSecret).callback(cbUrl)
.build();
return service;
}
示例15: createService
import org.scribe.builder.ServiceBuilder; //导入依赖的package包/类
/**
* OAuthService オブジェクトを生成
*
* Consumer Key (API Key), Consumer Secret (API Secret)
* 事前に、Google Developers Consoleで、入手した値を設定します。
*
* コールバックURL不要
*/
private void createService() {
Log.v(TAG, "createService called");
if (mService != null) {
return;
}
mService = new ServiceBuilder()
.provider(Google2Api.class)
.apiKey(mClientKey)
.apiSecret(mClientSecret)
.scope(
"https://www.googleapis.com/auth/userinfo.profile " +
"https://www.googleapis.com/auth/userinfo.email " +
"https://www.googleapis.com/auth/plus.me"
)
.build();
Log.v(TAG, "OAuthServiceオブジェクトを生成しました。");
}