当前位置: 首页>>代码示例>>Java>>正文


Java ServiceBuilder类代码示例

本文整理汇总了Java中com.github.scribejava.core.builder.ServiceBuilder的典型用法代码示例。如果您正苦于以下问题:Java ServiceBuilder类的具体用法?Java ServiceBuilder怎么用?Java ServiceBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServiceBuilder类属于com.github.scribejava.core.builder包,在下文中一共展示了ServiceBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.github.scribejava.core.builder.ServiceBuilder; //导入依赖的package包/类
public static void main (String[] args) {
    ResourceBundle secrets = ResourceBundle.getBundle("facebookutil/secret");
    final OAuth20Service service = new ServiceBuilder()
            .apiKey(secrets.getString("clientId"))
            .apiSecret(secrets.getString("clientSecret"))
            .callback("https://duke.edu/")
            .grantType("client_credentials")
            .build(FacebookApi.instance());
    String url = "https://graph.facebook.com/oauth/access_token?";
    url = url + "&client_id" + "=" + secrets.getString("clientId");
    url = url + "&client_secret" + "=" + secrets.getString("clientSecret");
    url = url + "&grant_type" + "=" + "client_credentials";
    final OAuthRequest request =
            new OAuthRequest(Verb.GET, url, service);
    service.signRequest(new OAuth2AccessToken(""), request);
    System.out.println(request.getBodyContents());
    System.out.println(request.getUrl());
    Response response = request.send();
    System.out.println(response.getBody());
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:21,代码来源:TestAppLogin.java

示例2: facebookExample

import com.github.scribejava.core.builder.ServiceBuilder; //导入依赖的package包/类
public void facebookExample () {
    // Replace these with your client id and secret
    final String clientId = mySecrets.getString("facebookId");
    final String clientSecret = mySecrets.getString("facebookSecret");
    service = new ServiceBuilder()
            .apiKey(clientId)
            .apiSecret(clientSecret)
            .callback(CALLBACK_URL)
            // .grantType("client_credentials")
            .scope("publish_actions,email,public_profile")
            // .scope("publish_actions")
            .build(FacebookApi.instance());

    System.out.println();

    // Obtain the Authorization URL
    System.out.println("Fetching the Authorization URL...");
    final String authorizationUrl = service.getAuthorizationUrl();
    myPage.getEngine().load(authorizationUrl);
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:21,代码来源:BrowserView.java

示例3: twitterExample

import com.github.scribejava.core.builder.ServiceBuilder; //导入依赖的package包/类
public void twitterExample () {
    final String clientId = mySecrets.getString("twitterId");
    final String clientSecret = mySecrets.getString("twitterSecret");

    final OAuth10aService service = new ServiceBuilder()
            .apiKey(clientId)
            .apiSecret(clientSecret)
            .grantType("client_credentials")
            .build(TwitterApi.instance());

    System.out.println("=== Twitter's OAuth Workflow ===");
    System.out.println();

    twitterToken = service.getRequestToken();
    // Obtain the Authorization URL
    System.out.println("Fetching the Authorization URL...");
    System.out.println("request: " + twitterToken.toString());
    final String authorizationUrl = service.getAuthorizationUrl(twitterToken);
    myPage.getEngine().load(authorizationUrl);
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:21,代码来源:BrowserView.java

示例4: googleExample

import com.github.scribejava.core.builder.ServiceBuilder; //导入依赖的package包/类
public void googleExample () {
    // Replace these with your client id and secret
    final String clientId = mySecrets.getString("googleId");
    final String clientSecret = mySecrets.getString("googleSecret");
    service = new ServiceBuilder()
            .apiKey(clientId)
            .apiSecret(clientSecret)
            .callback(CALLBACK_URL)
            // .scope("https://www.googleapis.com/auth/plus.login ")
            .scope("https://www.googleapis.com/auth/plus.circles.write https://www.googleapis.com/auth/plus.circles.read https://www.googleapis.com/auth/plus.stream.write https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/plus.stream.read")

            .build(GoogleApi20.instance());

    System.out.println();

    // Obtain the Authorization URL
    System.out.println("Fetching the Authorization URL...");
    final String authorizationUrl = service.getAuthorizationUrl();
    myPage.getEngine().load(authorizationUrl);
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:21,代码来源:BrowserView.java

示例5: Auth

import com.github.scribejava.core.builder.ServiceBuilder; //导入依赖的package包/类
public Auth(String clientId, String clientSecret, String callbackURL) throws NoSuchAlgorithmException {
    this.clientId = clientId;
    this.clientSecret = clientSecret;
    this.gson = new Gson();
    this.authUsers = new ArrayList<>();
    // TODO: this is where authorized users are hardcoded
    // The email address must be one managed by Google
    //authUsers.add("[email protected]");
    this.globalService = new ServiceBuilder()
            .apiKey(clientId)
            .apiSecret(clientSecret)
            .scope("email") // replace with desired scope
            .callback(callbackURL)
            .build(GoogleApi20.instance());

    KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
    keyPairGenerator.initialize(2048);
    this.keyPair = keyPairGenerator.genKeyPair();
    this.callbackURL = callbackURL;
}
 
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-4-dorfner-v2,代码行数:21,代码来源:Auth.java

示例6: getAuthURL

import com.github.scribejava.core.builder.ServiceBuilder; //导入依赖的package包/类
/**
 * @return A string containing a URL that we can send visitors to in order to authenticate them
 */
public String getAuthURL(String originatingURL){
    // I think we have to create a new service for every request we send out
    // since each one needs a different secretState
    final OAuth20Service service = new ServiceBuilder()
            .apiKey(clientId)
            .apiSecret(clientSecret)
            .scope("email") // replace with desired scope
            .state(generateSharedGoogleSecret(originatingURL))
            .callback(callbackURL)
            .build(GoogleApi20.instance());

    final Map<String, String> additionalParams = new HashMap<>();
    additionalParams.put("access_type", "offline");
    additionalParams.put("prompt", "consent");
    final String authorizationUrl = service.getAuthorizationUrl(additionalParams);

    return authorizationUrl;
}
 
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-4-dorfner-v2,代码行数:22,代码来源:Auth.java

示例7: onCreate

import com.github.scribejava.core.builder.ServiceBuilder; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_log_in_to_ttn);

    clientId = getString(R.string.oauth_client_id);
    clientSecret = getString(R.string.oauth_client_secret);
    redirectURI = getString(R.string.oauth_redirect_url);

    service = new ServiceBuilder()
            .apiKey(clientId)
            .apiSecret(clientSecret)
            .state(secretState)
            .callback(redirectURI)
            .build(TheThingsNetworkOathApi.instance());

    MyApplication mApplication = (MyApplication)getApplicationContext();
    mApplication.ttnApplications = new ArrayList<>();
    mApplication.chosenTtnApplication = null;

    Answers.getInstance().logCustom(new CustomEvent("Device configure").putCustomAttribute("method", "oauth2"));

    loadLoginPage();
}
 
开发者ID:jpmeijers,项目名称:ttnmapper_android_v2,代码行数:25,代码来源:LogInToTTN.java

示例8: getService

import com.github.scribejava.core.builder.ServiceBuilder; //导入依赖的package包/类
/**
 * Gets the OAuth Service.
 *
 * @return the OAuth Service
 */
@SuppressWarnings("unchecked")
public OAuthService getService() {
	if (this.service == null){
		if (config.getScope().length()>0){
			this.service = new ServiceBuilder().provider(config.getApiClass())
					.apiKey(config.getApiKey())
				    .apiSecret(config.getApiSecret())
				    .callback(config.getCallback())
				    .scope(config.getScope())
				    .build();				
		}
		else {
			this.service = new ServiceBuilder().provider(config.getApiClass())
					.apiKey(config.getApiKey())
				    .apiSecret(config.getApiSecret())
				    .callback(config.getCallback())
				    .build();							
		}
	}
	return service;
}
 
开发者ID:rmap-project,项目名称:rmap,代码行数:27,代码来源:OAuthProvider.java

示例9: doInBackground

import com.github.scribejava.core.builder.ServiceBuilder; //导入依赖的package包/类
protected AccountData doInBackground(Void... voids) {
    AccountData aData = new AccountData();

    //Build the OAuth service
    final OAuth10aService service = new ServiceBuilder()
            .apiKey(apiKeys.CONSUMER_KEY)
            .apiSecret(apiKeys.CONSUMER_SECRET)
            .build(TradeKingApi.instance());
    Token accessToken = new Token(apiKeys.OAUTH_TOKEN, apiKeys.OAUTH_TOKEN_SECRET);

    // Fetch the JSON data
    OAuthRequest request = new OAuthRequest(Verb.GET, tk.getFullAccountInfo(), service);
    service.signRequest(accessToken, request);
    Response response = request.send();

    //parse json
    try {
        aData = parseJSON(response);
    } catch (JSONException e) {
        e.printStackTrace();
        aData.setError(e.toString());
    }

    return aData;
}
 
开发者ID:mikemey01,项目名称:Markets,代码行数:26,代码来源:ParseAccountData.java

示例10: doInBackground

import com.github.scribejava.core.builder.ServiceBuilder; //导入依赖的package包/类
protected StockQuote doInBackground(Void... voids){
    //pause for a second so we don't get rate limited
    SystemClock.sleep(1000);

    //Build the OAuth service
    final OAuth10aService service = new ServiceBuilder()
            .apiKey(apiKeys.CONSUMER_KEY)
            .apiSecret(apiKeys.CONSUMER_SECRET)
            .build(TradeKingApi.instance());
    Token accessToken = new Token(apiKeys.OAUTH_TOKEN, apiKeys.OAUTH_TOKEN_SECRET);

    // Fetch the JSON data
    OAuthRequest request = new OAuthRequest(Verb.GET, tk.getMarketQuote(symbol), service);
    service.signRequest(accessToken, request);
    Response response = request.send();

    StockQuote quote = new StockQuote(symbol);
    try {
        quote = parseJSON(response);
    } catch (JSONException e) {
        e.printStackTrace();
        quote.setError(e.toString());
    }

    return quote;
}
 
开发者ID:mikemey01,项目名称:Markets,代码行数:27,代码来源:ParseStockQuote.java

示例11: doInBackground

import com.github.scribejava.core.builder.ServiceBuilder; //导入依赖的package包/类
protected Double doInBackground(Void... voids){
    double ret = 0.0;

    //Build the OAuth service
    final OAuth10aService service = new ServiceBuilder()
            .apiKey(apiKeys.CONSUMER_KEY)
            .apiSecret(apiKeys.CONSUMER_SECRET)
            .build(TradeKingApi.instance());
    Token accessToken = new Token(apiKeys.OAUTH_TOKEN, apiKeys.OAUTH_TOKEN_SECRET);

    // Fetch the JSON data
    OAuthRequest request = new OAuthRequest(Verb.GET, tk.getOptionStrikePrices(symbol), service);
    service.signRequest(accessToken, request);
    Response response = request.send();

    try {
        ret = parseJSON(response);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    return ret;
}
 
开发者ID:mikemey01,项目名称:Markets,代码行数:24,代码来源:ParseOptionStrikePrice.java

示例12: doInBackground

import com.github.scribejava.core.builder.ServiceBuilder; //导入依赖的package包/类
protected OptionOrder doInBackground(Void... voids){
    OptionOrder order = new OptionOrder();

    //Build the OAuth service
    final OAuth10aService service = new ServiceBuilder()
            .apiKey(apiKeys.CONSUMER_KEY)
            .apiSecret(apiKeys.CONSUMER_SECRET)
            .build(TradeKingApi.instance());
    Token accessToken = new Token(apiKeys.OAUTH_TOKEN, apiKeys.OAUTH_TOKEN_SECRET);

    // Fetch the JSON data
    OAuthRequest request = new OAuthRequest(Verb.POST, tk.getMarketOptionLive(), service);
    //request.addHeader("TKI_OVERRIDE", "true");
    request.addPayload(fixml.getLimitFixmlString());
    service.signRequest(accessToken, request);
    Response response = request.send();

    try {
        order = parseJSON(response);
    } catch (JSONException e) {
        e.printStackTrace();
        order.setError(e.toString());
    }

    return order;
}
 
开发者ID:mikemey01,项目名称:Markets,代码行数:27,代码来源:ParseOptionOrder.java

示例13: doInBackground

import com.github.scribejava.core.builder.ServiceBuilder; //导入依赖的package包/类
protected OptionOrderPreview doInBackground(Void... voids){
    OptionOrderPreview order = new OptionOrderPreview();

    //Build the OAuth service
    final OAuth10aService service = new ServiceBuilder()
            .apiKey(apiKeys.CONSUMER_KEY)
            .apiSecret(apiKeys.CONSUMER_SECRET)
            .build(TradeKingApi.instance());
    Token accessToken = new Token(apiKeys.OAUTH_TOKEN, apiKeys.OAUTH_TOKEN_SECRET);

    // Fetch the JSON data
    OAuthRequest request = new OAuthRequest(Verb.POST, tk.getMarketOptionPreview(), service);
    request.addPayload(fixml.getMarketFixmlString());
    service.signRequest(accessToken, request);
    Response response = request.send();

    try {
        order = parseJSON(response);
    } catch (JSONException e) {
        e.printStackTrace();
        order.setError(e.toString());
    }

    return order;
}
 
开发者ID:mikemey01,项目名称:Markets,代码行数:26,代码来源:ParseOptionOrderPreview.java

示例14: doGet

import com.github.scribejava.core.builder.ServiceBuilder; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	String providerName = StringUtils.substringAfterLast(req.getRequestURI(), "/");
	LOGGER.info("Authz request for provider: [{}]", providerName);
	OAuthProvider provider = this.providerFactory.getProvider(providerName);
	LOGGER.info("OAuthProvider: [{}]", provider);
	OAuth20Service oauth2Service = this.providerFactory.getOAuth2Service(providerName);
	if (oauth2Service == null) {
		oauth2Service = new ServiceBuilder().apiKey(provider.getApiKey()).apiSecret(provider.getApiSecret())
				.callback(provider.getCallbackURL()).build(provider.getApi());
		this.providerFactory.addOAuth2Service(providerName, oauth2Service);
	}
	String authorizationUrl = oauth2Service.getAuthorizationUrl();
	LOGGER.info("Authz URL: [{}]", authorizationUrl);
	resp.sendRedirect(authorizationUrl);
}
 
开发者ID:AdeptJ,项目名称:adeptj-modules,代码行数:17,代码来源:OAuth2AuthorizationRequestServlet.java

示例15: login

import com.github.scribejava.core.builder.ServiceBuilder; //导入依赖的package包/类
@RequestMapping("/login")
public OAuthResponse login()
{
	UUID uuid = UUID.randomUUID();

	State state = new State();
	state.setUuid(uuid);
	state.setApiVersion(RuneLiteAPI.getVersion());

	OAuth20Service service = new ServiceBuilder()
		.apiKey(oauthClientId)
		.apiSecret(oauthClientSecret)
		.scope(SCOPE)
		.callback(RL_OAUTH_URL)
		.state(gson.toJson(state))
		.build(GoogleApi20.instance());

	String authorizationUrl = service.getAuthorizationUrl();

	OAuthResponse lr = new OAuthResponse();
	lr.setOauthUrl(authorizationUrl);
	lr.setUid(uuid);

	return lr;
}
 
开发者ID:runelite,项目名称:runelite,代码行数:26,代码来源:AccountService.java


注:本文中的com.github.scribejava.core.builder.ServiceBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。