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


Java OAuthService.getAuthorizationUrl方法代碼示例

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


在下文中一共展示了OAuthService.getAuthorizationUrl方法的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: oAuth

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
private void oAuth() {
    // Replace these with your own api key and secret
    OAuthService service = FlickrForPalabreApplication.getoAuthService();
    Token mRequestToken = FlickrForPalabreApplication.getRequestToken();

    if (mRequestToken == null) {
        new Handler(Looper.getMainLooper()).post(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(MainActivity.this, getString(R.string.oauth_connection_error), Toast.LENGTH_LONG).show();
            }
        });
        return;
    }

    final String authorizationUrl = service.getAuthorizationUrl(mRequestToken);
    SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(MainActivity.this).edit();
    editor.putString(SharedPreferenceKeys.TOKEN_TOKEN, mRequestToken.getToken())
            .putString(SharedPreferenceKeys.TOKEN_SECRET, mRequestToken.getSecret())
            .putString(SharedPreferenceKeys.TOKEN_RESPONSE, mRequestToken.getRawResponse())
            .apply();

    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authorizationUrl)));

}
 
開發者ID:levelup,項目名稱:palabre-extensions,代碼行數:26,代碼來源:MainActivity.java

示例4: 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

示例5: 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

示例6: sendForAuthorization

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
private void sendForAuthorization(HttpServletRequest request, HttpServletResponse response, OAuthService service) {
	String retUrl = (String) request.getAttribute("javax.servlet.forward.request_uri");

	if (request.getSession().getAttribute("OAUTH_REDIRECT") != null) {
		retUrl = (String) request.getSession().getAttribute("OAUTH_REDIRECT");
	}
	if (request.getParameter("referrer") != null) {
		retUrl = request.getParameter("referrer");
	}
	request.getSession().setAttribute("OAUTH_REDIRECT", retUrl);

	String authorizationUrl = service.getAuthorizationUrl(null);
	response.reset();
	response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
	response.setHeader("Location", authorizationUrl);
	return;
}
 
開發者ID:dotCMS,項目名稱:plugin-dotcms-oauth,代碼行數:18,代碼來源:OAuth2Servlet.java

示例7: 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

示例8: main

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    System.out.println("Paste the consumerKey here");
    System.out.print(">>");
    String apiKey = in.nextLine();

    System.out.println("Paste the consumerSecret here");
    System.out.print(">>");
    String apiSecret = in.nextLine();

    OAuthService service = new ServiceBuilder()
        .provider(YammerApi.class)
        .apiKey(apiKey)
        .apiSecret(apiSecret)
        .build();

    String authorizationUrl = service.getAuthorizationUrl(EMPTY_TOKEN);
    System.out
            .println("Go and authorize your app here (eg. in a web browser):");
    System.out.println(authorizationUrl);
    System.out.println("... and paste the authorization code here");
    System.out.print(">>");
    Verifier verifier = new Verifier(in.nextLine());

    System.out.println();

    Token accessToken = service.getAccessToken(EMPTY_TOKEN, verifier);
    System.out.println("Your Access Token is: " + accessToken);
    System.out.println();

    in.close();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:34,代碼來源:YammerAccessCodeGenerator.java

示例9: loginURL

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
private String loginURL(@NonNull String redirectURL) {
    Preconditions.checkArgument(redirectURL.startsWith("/"));

    OAuthService service = new ServiceBuilder()
            .provider(FacebookApi.class)
            .apiKey(apiKey)
            .apiSecret(apiSecret)
            .callback(host + redirectURL)
            .scope("email")
            .build();
    return service.getAuthorizationUrl(null);
}
 
開發者ID:cilogi,項目名稱:lid,代碼行數:13,代碼來源:FacebookLoginServlet.java

示例10: 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

示例11: 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

示例12: testInstagram

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
@Test
public void testInstagram()
{
     OAuthService service = new ServiceBuilder()
        .provider(Instagram2Api.class)
        .apiKey(OurOAuthParams.INSTAGRAM_API_KEY)
        .apiSecret(OurOAuthParams.INSTAGRAM_API_SECRET)
        .callback(ClientUtils.getCallbackUrl())
        .build();
    
    Token requestToken = null;
    String authorizationUrl = service.getAuthorizationUrl(requestToken);
    logger.info("authorization url: " + authorizationUrl);       
}
 
開發者ID:muquit,項目名稱:gwtoauthlogindemo,代碼行數:15,代碼來源:TestGWTOAuthLoginDemo.java

示例13: 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

示例14: 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

示例15: initiatingAuthentication

import org.scribe.oauth.OAuthService; //導入方法依賴的package包/類
private void initiatingAuthentication(HttpServletRequest request, HttpServletResponse response,
        HttpSession session, OAuthService service) throws IOException {

    LOG.info(LOG_MESSAGE_AUTH_INITIATING, new Object[] { request.getRemoteAddr() });

    session.setAttribute(ENTRY_URL, request.getRequestURL());

    // The request token doesn't matter for OAuth 2.0 which is why it's null
    String authUrl = service.getAuthorizationUrl(null);
    response.sendRedirect(authUrl);
}
 
開發者ID:inbloom,項目名稱:secure-data-service,代碼行數:12,代碼來源:SLIAuthenticationEntryPoint.java


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