當前位置: 首頁>>代碼示例>>Java>>正文


Java OAuthService.getRequestToken方法代碼示例

本文整理匯總了Java中org.scribe.oauth.OAuthService.getRequestToken方法的典型用法代碼示例。如果您正苦於以下問題:Java OAuthService.getRequestToken方法的具體用法?Java OAuthService.getRequestToken怎麽用?Java OAuthService.getRequestToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.scribe.oauth.OAuthService的用法示例。


在下文中一共展示了OAuthService.getRequestToken方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: redirectUserToGrantAccess

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
@Override
protected String redirectUserToGrantAccess()
{
    try
    {
        OAuthService service = createOAuthScribeService();
        Token requestToken = service.getRequestToken();
        String authUrl = service.getAuthorizationUrl(requestToken);

        request.getSession().setAttribute("requestToken", requestToken);

        return SystemUtils.getRedirect(this, authUrl, true);

    } catch (Exception e)
    {
        addErrorMessage("Cannot proceed authentication, check OAuth credentials for account " + getOrganizationName());
        return INPUT;
    }
}
 
開發者ID:edgehosting,項目名稱:jira-dvcs-connector,代碼行數:20,代碼來源:RegenerateBitbucketOauthToken.java

示例2: redirectUserToBitbucket

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
private String redirectUserToBitbucket()
{
    try
    {
        OAuthService service = createOAuthScribeService();
        Token requestToken = service.getRequestToken();
        String authUrl = service.getAuthorizationUrl(requestToken);

        request.getSession().setAttribute(SESSION_KEY_REQUEST_TOKEN, requestToken);

        return SystemUtils.getRedirect(this, authUrl, true);
    }
    catch (Exception e)
    {
        log.warn("Error redirect user to bitbucket server.", e);
        addErrorMessage("The authentication with Bitbucket has failed. Please check your OAuth settings.");
        triggerAddFailedEvent(FAILED_REASON_OAUTH_TOKEN);
        return INPUT;
    }
}
 
開發者ID:edgehosting,項目名稱:jira-dvcs-connector,代碼行數:21,代碼來源:AddBitbucketOrganization.java

示例3: doRequestAuth

import org.scribe.oauth.OAuthService; //導入方法依賴的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 );
}
 
開發者ID:iTwenty,項目名稱:Hashtagger,代碼行數:23,代碼來源:TwitterService.java

示例4: authorize

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
private Token authorize() {
	OAuthService service = new ServiceBuilder()
			.provider(CubeSensorsAuthApi.class)
			.apiKey(CubeSensorsProperties.getAppKey())
			.apiSecret(CubeSensorsProperties.getAppSecret())
			.signatureType(SignatureType.QueryString).build();

	Token requestToken = service.getRequestToken();
	String authorizationUrl = service.getAuthorizationUrl(requestToken);

	String authorization = authProvider.getAuthorization(authorizationUrl);

	Token accessToken = service.getAccessToken(requestToken, new Verifier(
			authorization));

	return accessToken;
}
 
開發者ID:1337joe,項目名稱:cubesensors-for-java,代碼行數:18,代碼來源:CubeSensorsUtils.java

示例5: testYahoo

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
@Test
public void testYahoo()
{
    OAuthService service = new ServiceBuilder()
        .provider(YahooApi.class)
        .apiKey(OurOAuthParams.YAHOO_API_KEY)
        .apiSecret(OurOAuthParams.YAHOO_API_SECRET)
        .callback(ClientUtils.getCallbackUrl())
        .build();
    System.out.println("Getting request token");
    try
    {
        Token requestToken = service.getRequestToken();
        System.out.println("Got request token");
    }
    catch (Exception e)
    {
        System.out.println("Exception: " + e);
    }
}
 
開發者ID:muquit,項目名稱:gwtoauthlogindemo,代碼行數:21,代碼來源:TestGWTOAuthLoginDemo.java

示例6: getToken

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
@Background
public void getToken() {
    final String apiKey = getString(R.string.api_key);
    final String apiSecret = getString(R.string.api_secret);
    final String callback = getString(R.string.api_callback);
    final OAuthService service = new ServiceBuilder()
            .provider(new RavelryApi(getString(R.string.ravelry_oauth_url)))
            .apiKey(apiKey).apiSecret(apiSecret).callback(callback).build();

    final Token requestToken;
    try {
        requestToken = service.getRequestToken();
    } catch (Exception e) {
        AQUtility.report(e);
        moveTaskToBack(true);
        return;
    }
    final String authURL = service.getAuthorizationUrl(requestToken);

    callAuthPage(callback, service, requestToken, authURL);
}
 
開發者ID:KoljaTM,項目名稱:Yarrn,代碼行數:22,代碼來源:GetAccessTokenActivity.java

示例7: obtainsAccessToken

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
/**
 * Odesk access token can be obtained through OAuth.
 * @throws Exception If some problem inside
 */
@Test
public void obtainsAccessToken() throws Exception {
    Assume.assumeThat(RtOdeskOauthExample.KEY, Matchers.notNullValue());
    final OAuthService service = new ServiceBuilder()
        .provider(OAuthWire.OdeskApi.class)
        .apiKey(RtOdeskOauthExample.KEY)
        .apiSecret(RtOdeskOauthExample.SECRET)
        .build();
    final Token rqst = service.getRequestToken();
    Logger.info(
        this, "authorization URL: %s (open it in a browser)",
        service.getAuthorizationUrl(rqst)
    );
    Logger.info(this, "enter Odesk verifier and press ENTER:");
    final Scanner input = new Scanner(System.in);
    final Verifier verifier = new Verifier(input.nextLine());
    final Token access = service.getAccessToken(rqst, verifier);
    Logger.info(this, "access token is: %s", access.getToken());
    Logger.info(this, "access token secret is: %s", access.getSecret());
}
 
開發者ID:jcabi,項目名稱:jcabi-odesk,代碼行數:25,代碼來源:RtOdeskOauthExample.java

示例8: getAuthUrl

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
@Override
public Response getAuthUrl(long customerId, int clientId) {
    if (!IdPool.clientInList(customerId, clientId)) {
        clientNotFoundMsg.setCustomerId(customerId);
        clientNotFoundMsg.setClientId(clientId);
        return Response.status(Response.Status.OK).entity(clientNotFoundMsg).type(MediaType.APPLICATION_JSON_TYPE).build();
    }

    customer = LinkedInCustomerResource.getCustomerList().get(customerId);
    client = customer.getClientDB().getClientList().get(clientId);

    AuthUrlMsg msg = new AuthUrlMsg();
    msg.setCustomerId(customerId);
    msg.setClientId(clientId);
    msg.setLinkStatus(client.getStatus());

    if (client.getLinkHandler().getRequestAuthUrl() == null) {
        OAuthService serviceProvider = new ServiceBuilder().provider(LinkedInApi.class).apiKey(API_KEY).apiSecret(API_SECRET).build();

        // pass the serviceProvider obj to LinkHandler
        client.getLinkHandler().setServiceProvider(serviceProvider);

        //to get request token
        requestToken = serviceProvider.getRequestToken();
        client.getLinkHandler().setRequestToken(requestToken);

        // use request token to get auth url
        requestAuthUrl = serviceProvider.getAuthorizationUrl(requestToken);
        client.getLinkHandler().setRequestAuthUrl(requestAuthUrl);

        msg.setRequestUrl(requestAuthUrl);


        return Response.status(Response.Status.OK).entity(msg).type(MediaType.APPLICATION_JSON_TYPE).build();
    } else {

        return Response.status(Response.Status.OK).entity(msg).type(MediaType.APPLICATION_JSON_TYPE).build();
    }

}
 
開發者ID:ZhengshuaiPENG,項目名稱:HiringSmV02,代碼行數:41,代碼來源:LinkedInAppResource.java

示例9: authorize

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
@Test
@Ignore("Not suitable as automatic unit test. Requires manual action.")
public void authorize() throws URISyntaxException, IOException {
    final String key = System.getProperty("key");
    final String secret = System.getProperty("secret");
    assertNotNull("You must use a discogs key via System property -Dkey=", key);
    assertNotNull("You must use a discogs secret via System property -Dsecret=", secret);
    assertNotNull("You must use a custom user agent via System property -Dhttp.agent=", System.getProperty("http.agent"));
    final OAuthService service = new ServiceBuilder()
            .provider(DiscogsApi.class)
            .apiKey(key)
            .apiSecret(secret)
            .debug()
            .build();
    final Token requestToken = service.getRequestToken();
    System.out.println("Token: " + requestToken);
    final String authorizationUrl = service.getAuthorizationUrl(requestToken);
    System.out.println("AuthorizationUrl: " + authorizationUrl);

    Desktop.getDesktop().browse(new URI(authorizationUrl));
    System.out.println("Please enter token: ");
    final String token = System.console().readLine();
    System.out.println("Got " + token);
    final Verifier verifier = new Verifier(token);

    // Trade the Request Token and Verifier for the Access Token
    final Token accessToken = service.getAccessToken(requestToken, verifier);

    final OAuthRequest request = new OAuthRequest(Verb.GET, "https://api.discogs.com/image/R-944131-1175701834.jpeg");
    service.signRequest(accessToken, request);
    final Response response = request.send();
    System.out.println(response.getCode() + " " + response.getMessage());
}
 
開發者ID:hendriks73,項目名稱:coxy,代碼行數:34,代碼來源:DiscogsApiTest.java

示例10: login

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
private static void login() {
	try {
		fos = new FileOutputStream(JasauFileHelper.getSaveDirectory(JasauFileHelper.savePrefix, "OutputTemp"));
	} catch (IOException e) {
		e.printStackTrace();
	}
	
	OAuthService service = new ServiceBuilder().provider(TumblrApi.class).apiKey(ConsumerKey).apiSecret(ConsumerSecret).callback("http://127.0.0.1").debugStream(fos).build();
	Token requestToken = service.getRequestToken();
	String authUrl = service.getAuthorizationUrl(requestToken);
	
	try {
		Desktop.getDesktop().browse(new URI(authUrl));
	} catch (IOException | URISyntaxException e1) {
		e1.printStackTrace();
	}
	
	try {
		JasauFileHelper.readFromTempFile();
	} catch (IOException e2) {
		e2.printStackTrace();
	}
	
	try {
		JasauFileHelper.writeTokenToFile();
	} catch (IOException e3) {
		e3.printStackTrace();
	}
	setClientToken();
}
 
開發者ID:chazwarp923,項目名稱:Just-A-Simple-Auto-Uploader,代碼行數:31,代碼來源:Main.java

示例11: auth

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
public String auth(final Shell shell) throws MalformedURLException, InterruptedException {
    try {
        Class<? extends EvernoteApi> apiClass = EvernoteUtil.brand().scribeOAuthApi();
        OAuthService service = new ServiceBuilder().provider(apiClass).apiKey(CONSUMER_KEY).apiSecret(EncryptionUtil.decrypt(CONSUMER_SECRET)).callback(callback.getCallbackURL()).build();
        Token requestToken = service.getRequestToken();
        String authUrl = service.getAuthorizationUrl(requestToken);
        try {
            PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL(authUrl));
        } catch (PartInitException couldNotOpenBrowser) {
            LinkedHashMap<String, String> btns = MapUtil.orderedMap();
            btns.put(Constants.Plugin_OAuth_Copy, Messages.Plugin_OAuth_Copy);
            btns.put(Constants.Plugin_OAuth_Cancel, Messages.Plugin_OAuth_Cancel);

            String opt = new SyncEclipseUtil().openCustomImageTypeWithCustomButtonsSyncly(shell, Messages.Plugin_OAuth_Title, Messages.Plugin_OAuth_DoItManually, new Image(Display.getDefault(), getClass().getClassLoader().getResourceAsStream(Constants.OAUTH_EVERNOTE_TRADEMARK)), btns);
            if (Constants.Plugin_OAuth_Copy.equals(opt)) {
                ClipboardUtil.copy(authUrl);
            } else {
                return StringUtils.EMPTY;
            }
        }

        // wait for callback handling
        synchronized (callback) {
            callback.wait(30 * 60 * 1000);// 30 minutes
        }

        String verifierValue = callback.getVerifier();
        if (StringUtils.isBlank(verifierValue)) {
            return StringUtils.EMPTY;
        }
        Verifier verifier = new Verifier(verifierValue);
        Token accessToken = service.getAccessToken(requestToken, verifier);
        return accessToken.getToken();
    } finally {
        callback.done();
    }
}
 
開發者ID:LTTPP,項目名稱:Eemory,代碼行數:38,代碼來源:OAuth.java

示例12: doInBackground

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
@Override
protected String doInBackground(Void... params) {
    String url = null;
    try {

        EvernoteSession session = EvernoteSession.getOpenSession();
        if (session != null) {
            //Network request
            BootstrapManager.BootstrapInfoWrapper infoWrapper = session.getBootstrapSession().getBootstrapInfo();

            if (infoWrapper != null) {
                BootstrapInfo info = infoWrapper.getBootstrapInfo();
                if (info != null) {
                    mBootstrapProfiles = (ArrayList<BootstrapProfile>) info.getProfiles();
                    if (mBootstrapProfiles != null &&
                            mBootstrapProfiles.size() > 0 &&
                            mSelectedBootstrapProfilePos < mBootstrapProfiles.size()) {

                        mSelectedBootstrapProfile = mBootstrapProfiles.get(mSelectedBootstrapProfilePos);
                    }
                }
            }
        }

        if (mSelectedBootstrapProfile == null || TextUtils.isEmpty(mSelectedBootstrapProfile.getSettings().getServiceHost())) {
            Log.d(LOGTAG, "Bootstrap did not return a valid host");
            return null;
        }

        OAuthService service = createService();

        Log.i(LOGTAG, "Retrieving OAuth request token...");
        Token reqToken = service.getRequestToken();
        mRequestToken = reqToken.getToken();
        mRequestTokenSecret = reqToken.getSecret();

        Log.i(LOGTAG, "Redirecting user for authorization...");
        url = service.getAuthorizationUrl(reqToken);
        if (mSupportAppLinkedNotebooks) {
            url += "&supportLinkedSandbox=true";
        }
    } catch (BootstrapManager.ClientUnsupportedException cue) {

        return null;
    } catch (Exception ex) {
        Log.e(LOGTAG, "Failed to obtain OAuth request token", ex);
    }
    return url;
}
 
開發者ID:duanze,項目名稱:PureNote,代碼行數:50,代碼來源:EvernoteOAuthActivity.java

示例13: main

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
public static void main(String[] args)
{
  OAuthService service = new ServiceBuilder()
                              .provider(MeetupApi.class)
                              .apiKey("j1khkp0dus323ftve0sdcv6ffe")
                              .apiSecret("6s6gt6q59gvfjtsvgcmht62gq4")
                              .build();
  Scanner in = new Scanner(System.in);

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

  // Obtain the Request Token
  System.out.println("Fetching the Request Token...");
  Token requestToken = service.getRequestToken();
  System.out.println("Got the Request Token!");
  System.out.println();

  System.out.println("Now go and authorize Scribe here:");
  System.out.println(service.getAuthorizationUrl(requestToken));
  System.out.println("And paste the verifier here");
  System.out.print(">>");
  Verifier verifier = new Verifier(in.nextLine());
  System.out.println();

  // Trade the Request Token and Verfier for the Access Token
  System.out.println("Trading the Request Token for an Access Token...");
  Token accessToken = service.getAccessToken(requestToken, verifier);
  System.out.println("Got the Access Token!");
  System.out.println("(if your curious it looks like this: " + accessToken + " )");
  System.out.println();

  // Now let's go and ask for a protected resource!
  System.out.println("Now we're going to access a protected resource...");
  OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
  service.signRequest(accessToken, request);
  Response response = request.send();
  System.out.println("Got it! Lets see what we found...");
  System.out.println();
  System.out.println(response.getBody());

  System.out.println();
  System.out.println("Thats it man! Go and build something awesome with Scribe! :)");
}
 
開發者ID:visun,項目名稱:scribeoauth,代碼行數:45,代碼來源:MeetupExample.java

示例14: getAuthorizationKey

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
public AuthorizationKey getAuthorizationKey() {
	final OAuthService service = buildService(apiKey, apiSecret);
	final Token requestToken = service.getRequestToken();
	final String authorizationUrl = service.getAuthorizationUrl(requestToken);
	return new AuthorizationKey(authorizationUrl, requestToken);
}
 
開發者ID:sammyrulez,項目名稱:beatport-api,代碼行數:7,代碼來源:BeatportAuthService.java

示例15: doInBackground

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
@Override
protected String doInBackground(Void... params) {
	String url = null;
	try {

		EvernoteSession session = EvernoteSession.getOpenSession();
		if (session != null) {
			// Network request
			BootstrapManager.BootstrapInfoWrapper infoWrapper = session
					.getBootstrapSession().getBootstrapInfo();

			if (infoWrapper != null) {
				BootstrapInfo info = infoWrapper.getBootstrapInfo();
				if (info != null) {
					mBootstrapProfiles = (ArrayList<BootstrapProfile>) info
							.getProfiles();
					if (mBootstrapProfiles != null
							&& mBootstrapProfiles.size() > 0
							&& mSelectedBootstrapProfilePos < mBootstrapProfiles
									.size()) {

						mSelectedBootstrapProfile = mBootstrapProfiles
								.get(mSelectedBootstrapProfilePos);
					}
				}
			}
		}

		if (mSelectedBootstrapProfile == null
				|| TextUtils.isEmpty(mSelectedBootstrapProfile
						.getSettings().getServiceHost())) {
			Log.d(LOGTAG, "Bootstrap did not return a valid host");
			return null;
		}

		OAuthService service = createService();

		Log.i(LOGTAG, "Retrieving OAuth request token...");
		Token reqToken = service.getRequestToken();
		mRequestToken = reqToken.getToken();
		mRequestTokenSecret = reqToken.getSecret();

		Log.i(LOGTAG, "Redirecting user for authorization...");
		url = service.getAuthorizationUrl(reqToken);
	} catch (BootstrapManager.ClientUnsupportedException cue) {

		return null;
	} catch (Exception ex) {
		Log.e(LOGTAG, "Failed to obtain OAuth request token", ex);
	}
	return url;
}
 
開發者ID:daimajia,項目名稱:EverMemo,代碼行數:53,代碼來源:EvernoteOAuthActivity.java


注:本文中的org.scribe.oauth.OAuthService.getRequestToken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。