当前位置: 首页>>代码示例>>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;未经允许,请勿转载。