Java Code Examples for com.github.scribejava.core.builder.ServiceBuilder#build()

The following examples show how to use com.github.scribejava.core.builder.ServiceBuilder#build() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OAuthManagerProviders.java    From react-native-oauth with MIT License 6 votes vote down vote up
private static OAuth10aService twitterService(
  final HashMap cfg,
  @Nullable final ReadableMap opts,
  final String callbackUrl) {
  String consumerKey = (String) cfg.get("consumer_key");
  String consumerSecret = (String) cfg.get("consumer_secret");

  ServiceBuilder builder = new ServiceBuilder()
        .apiKey(consumerKey)
        .apiSecret(consumerSecret)
        .debug();

  String scopes = (String) cfg.get("scopes");
  if (scopes != null) {
    // String scopeStr = OAuthManagerProviders.getScopeString(scopes, "+");
    // Log.d(TAG, "scopeStr: " + scopeStr);
    // builder.scope(scopeStr);
  }

  if (callbackUrl != null) {
    builder.callback(callbackUrl);
  }

  return builder.build(TwitterApi.instance());
}
 
Example 2
Source File: OAuthManagerProviders.java    From react-native-oauth with MIT License 6 votes vote down vote up
private static OAuth20Service configurableService(
  final HashMap cfg,
  @Nullable final ReadableMap opts,
  final String callbackUrl
) {
  ServiceBuilder builder = OAuthManagerProviders._oauth2ServiceBuilder(cfg, opts, callbackUrl);
  Log.d(TAG, "Creating ConfigurableApi");
  //Log.d(TAG, "    authorize_url:     " + cfg.get("authorize_url"));
  //Log.d(TAG, "    access_token_url:  " + cfg.get("access_token_url"));
  ConfigurableApi api = ConfigurableApi.instance()
    .setAccessTokenEndpoint((String) cfg.get("access_token_url"))
    .setAuthorizationBaseUrl((String) cfg.get("authorize_url"));
  if (cfg.containsKey("access_token_verb")) {
    //Log.d(TAG, "    access_token_verb: " + cfg.get("access_token_verb"));
    api.setAccessTokenVerb((String) cfg.get("access_token_verb"));
  }

  return builder.build(api);
}
 
Example 3
Source File: OAuthManagerProviders.java    From react-native-oauth with MIT License 5 votes vote down vote up
private static OAuth20Service facebookService(
  final HashMap cfg,
  @Nullable final ReadableMap opts,
  final String callbackUrl) {
  ServiceBuilder builder = OAuthManagerProviders._oauth2ServiceBuilder(cfg, opts, callbackUrl);
  return builder.build(FacebookApi.instance());
}
 
Example 4
Source File: OAuthManagerProviders.java    From react-native-oauth with MIT License 5 votes vote down vote up
private static OAuth20Service googleService(
  final HashMap cfg,
  @Nullable final ReadableMap opts,
  final String callbackUrl)
{
  ServiceBuilder builder = OAuthManagerProviders._oauth2ServiceBuilder(cfg, opts, callbackUrl);
  return builder.build(GoogleApi20.instance());
}
 
Example 5
Source File: OAuthManagerProviders.java    From react-native-oauth with MIT License 5 votes vote down vote up
private static OAuth20Service githubService(
  final HashMap cfg,
  @Nullable final ReadableMap opts,
  final String callbackUrl)
{

  ServiceBuilder builder = OAuthManagerProviders._oauth2ServiceBuilder(cfg, opts, callbackUrl);
  return builder.build(GitHubApi.instance());
}
 
Example 6
Source File: OAuthManagerProviders.java    From react-native-oauth with MIT License 5 votes vote down vote up
private static OAuth20Service slackService(
  final HashMap cfg,
  @Nullable final ReadableMap opts,
  final String callbackUrl
  ) {

  Log.d(TAG, "Make the builder: " + SlackApi.class);
  ServiceBuilder builder = OAuthManagerProviders._oauth2ServiceBuilder(cfg, opts, callbackUrl);
  return builder.build(SlackApi.instance());
}
 
Example 7
Source File: DefaultOAuth2ServiceImpl.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
private OAuth20Service createService(OAuth2Service service) {
    IOAuth2Provider provider = service.getProvider();

    ServiceBuilder builder = new ServiceBuilder(service.getApiKey());

    builder.apiSecret(service.getApiSecret())
            .callback(service.getCallback());

    if (!Strings.isNullOrEmpty(provider.getScope())) {
        builder.defaultScope(provider.getScope());
    }

    return builder.build(provider.getInstance());
}