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


Java OAuthService类代码示例

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


OAuthService类属于org.scribe.oauth包,在下文中一共展示了OAuthService类的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: createBitbucketOAuthScribeService

import org.scribe.oauth.OAuthService; //导入依赖的package包/类
private OAuthService createBitbucketOAuthScribeService(String callbackUrl)
{
    Organization organizationInstance = organizationService.get(Integer.parseInt(organization), false);

    ServiceBuilder sb = new ServiceBuilder().apiKey(organizationInstance.getCredential().getOauthKey())
            .signatureType(SignatureType.Header).apiSecret(organizationInstance.getCredential().getOauthSecret())
            .provider(new Bitbucket10aScribeApi(organizationInstance.getHostUrl(), httpClientProvider))
            .debugStream(new DebugOutputStream(log));

    if (!StringUtils.isBlank(callbackUrl))
    {
        sb.callback(callbackUrl);
    }

    return sb.build();
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:17,代码来源:RegenerateBitbucketOauthToken.java

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

示例4: getAccessToken

import org.scribe.oauth.OAuthService; //导入依赖的package包/类
@Override
protected String getAccessToken()
{
    Verifier verifier = new Verifier(request.getParameter("oauth_verifier"));
    Token requestToken = (Token) request.getSession().getAttribute("requestToken");
    request.getSession().removeAttribute("requestToken");

    OAuthService service = createOAuthScribeService();
    Token accessTokenObj = null;
    try
    {
        accessTokenObj = service.getAccessToken(requestToken, verifier);
    } catch (OAuthConnectionException e)
    {
        Organization organizationInstance = organizationService.get(Integer.parseInt(organization), false);
        throw new SourceControlException("Error obtaining access token. Cannot access " + organizationInstance.getHostUrl() + " from Jira.", e);
    } finally
    {
        httpClientProvider.closeIdleConnections();
    }

    return BitbucketOAuthAuthentication.generateAccessTokenString(accessTokenObj);
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:24,代码来源:RegenerateBitbucketOauthToken.java

示例5: doFinish

import org.scribe.oauth.OAuthService; //导入依赖的package包/类
public String doFinish()
{
    // now get the access token
    Verifier verifier = new Verifier(request.getParameter("oauth_verifier"));
    Token requestToken = (Token) request.getSession().getAttribute(SESSION_KEY_REQUEST_TOKEN);

    if (requestToken == null)
    {
        log.debug("Request token is NULL. It has been removed in the previous attempt of adding organization. Now we will stop.");
        return getRedirect("ConfigureDvcsOrganizations.jspa?atl_token=" + CustomStringUtils.encode(getXsrfToken()));
    }

    request.getSession().removeAttribute(SESSION_KEY_REQUEST_TOKEN);

    OAuthService service = createOAuthScribeService();
    Token accessTokenObj = service.getAccessToken(requestToken, verifier);
    accessToken = BitbucketOAuthAuthentication.generateAccessTokenString(accessTokenObj);

    httpClientProvider.closeIdleConnections();

    return doAddOrganization();
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:23,代码来源:AddBitbucketOrganization.java

示例6: afterFinalUriConstructed

import org.scribe.oauth.OAuthService; //导入依赖的package包/类
@Override
protected String afterFinalUriConstructed(HttpRequestBase forMethod, String finalUri, Map<String, ? extends Object> parameters)
{
    long start = System.currentTimeMillis();
	//
	// generate oauth 1.0 params for 2LO - use scribe so far for that ...
	//
	OAuthService service = createOauthService();
	OAuthRequest request = new OAuthRequest(Verb.valueOf(forMethod.getMethod()), finalUri);

	addParametersForSigning(request, parameters);

	service.signRequest(new EmptyToken(), request);
	Map<String, String> oauthParams = request.getOauthParameters();
	//
	//
	log.debug("2LO signing took [{}] ms ", System.currentTimeMillis() - start);

	return finalUri + paramsToString(oauthParams, finalUri.indexOf("?") != -1);
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:21,代码来源:TwoLegged10aOauthRemoteRequestor.java

示例7: onConnectionCreated

import org.scribe.oauth.OAuthService; //导入依赖的package包/类
@Override
protected void onConnectionCreated(HttpClient client, HttpRequestBase method, Map<String, ? extends Object> parameters)
        throws IOException
{
    long start = System.currentTimeMillis();
    //
    // generate oauth 1.0 params for 3LO - use scribe so far for that ...
    //
    OAuthService service = createOauthService();
    OAuthRequest request = new OAuthRequest(Verb.valueOf(method.getMethod()), method.getURI().toString());

    addParametersForSigning(request, parameters);

    service.signRequest(generateAccessTokenObject(accessTokenWithSecret), request);

    String header = authHeaderCreator.extract(request);
    method.addHeader(OAuthConstants.HEADER, header);

    log.debug("3LO signing took [{}] ms ", System.currentTimeMillis() - start);
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:21,代码来源:ThreeLegged10aOauthRemoteRequestor.java

示例8: getUserInfoJSON

import org.scribe.oauth.OAuthService; //导入依赖的package包/类
private JSONObject getUserInfoJSON(String code, String callBackUrl) {
    OAuthService service = new ServiceBuilder()
            .provider(FacebookApi.class)
            .apiKey(apiKey)
            .apiSecret(apiSecret)
            .callback(host + callBackUrl)
            .scope("email")
            .build();
    Verifier verifier = new Verifier(code);
    Token accessToken = service.getAccessToken(NULL_TOKEN, verifier);
    OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
    request.addOAuthParameter("scope", "email");
    service.signRequest(accessToken, request);
    Response response = request.send();
    LOG.info("response body is " + response.getBody());
    try {
        JSONObject obj = new JSONObject(response.getBody());
        obj.put("access_token", accessToken.getToken());
        return obj;
    } catch (JSONException e) {
        return new JSONObject();
    }
}
 
开发者ID:cilogi,项目名称:lid,代码行数:24,代码来源:FacebookLoginServlet.java

示例9: provideOAuthService

import org.scribe.oauth.OAuthService; //导入依赖的package包/类
@Singleton
@Provides
public OAuthService provideOAuthService() {
	ServiceBuilder serviceBuilder = new ServiceBuilder()
					.apiKey(BuildConfig.GEOCACHING_API_KEY)
					.apiSecret(BuildConfig.GEOCACHING_API_SECRET)
					.callback(AppConstants.OAUTH_CALLBACK_URL)
					.debug();

	if (BuildConfig.GEOCACHING_API_STAGING) {
		serviceBuilder.provider(GeocachingOAuthProvider.Staging.class);
	} else {
		serviceBuilder.provider(GeocachingOAuthProvider.class);
	}

	return serviceBuilder.build();
}
 
开发者ID:arcao,项目名称:Trackables,代码行数:18,代码来源:GeocachingModule.java

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

示例11: createService

import org.scribe.oauth.OAuthService; //导入依赖的package包/类
@Override
public OAuthService createService(final OAuthConfig config) {
    return new OAuth20ServiceImpl(this, config) {
        @Override
        public Token getAccessToken(Token requestToken, Verifier verifier) {
            //basic auth, as described at https://developer.atlassian.com/static/bitbucket/concepts/oauth2.html
            OAuthRequest request = new OAuthRequest(getAccessTokenVerb(), getAccessTokenEndpoint());

            //basic auth
            request.addHeader("Authorization", "Basic "+Base64Encoder.getInstance().encode((config.getApiKey()+":"+config.getApiSecret()).getBytes(StandardCharsets.UTF_8)));

            request.addBodyParameter(OAuthConstants.CODE, verifier.getValue());
            request.addBodyParameter(OAuthConstants.REDIRECT_URI, config.getCallback());

            request.addBodyParameter("grant_type", "authorization_code");
            Response response = request.send();
            return getAccessTokenExtractor().extract(response.getBody());
        }
    };
}
 
开发者ID:digitalfondue,项目名称:lavagna,代码行数:21,代码来源:Bitbucket20Api.java

示例12: createService

import org.scribe.oauth.OAuthService; //导入依赖的package包/类
@Override
public OAuthService createService(final OAuthConfig config) {
	return new OAuth20ServiceImpl(this, config) {
		@Override
		public Token getAccessToken(Token requestToken, Verifier verifier) {
			OAuthRequest request = new OAuthRequest(getAccessTokenVerb(), getAccessTokenEndpoint());
			request.addBodyParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
			request.addBodyParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
			request.addBodyParameter(OAuthConstants.CODE, verifier.getValue());
			request.addBodyParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
			request.addBodyParameter("grant_type", "authorization_code");
			if (config.hasScope()) {
				request.addBodyParameter(OAuthConstants.SCOPE, config.getScope());
			}
			Response response = request.send();
			return getAccessTokenExtractor().extract(response.getBody());
		}
	};
}
 
开发者ID:digitalfondue,项目名称:lavagna,代码行数:20,代码来源:Google20Api.java

示例13: createService

import org.scribe.oauth.OAuthService; //导入依赖的package包/类
@Override
public OAuthService createService(final OAuthConfig config) {
    return new OAuth20ServiceImpl(this, config) {
        @Override
        public Token getAccessToken(Token requestToken, Verifier verifier) {
            OAuthRequest request = new OAuthRequest(getAccessTokenVerb(), getAccessTokenEndpoint());
            request.addBodyParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
            request.addBodyParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
            request.addBodyParameter(OAuthConstants.CODE, verifier.getValue());
            request.addBodyParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
            // well, the doc is not correct, see https://github.com/gitlabhq/gitlabhq/issues/9141
            request.addBodyParameter("grant_type", "authorization_code");
            Response response = request.send();
            return getAccessTokenExtractor().extract(response.getBody());
        }
    };
}
 
开发者ID:digitalfondue,项目名称:lavagna,代码行数:18,代码来源:Gitlab20Api.java

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

示例15: doAuth

import org.scribe.oauth.OAuthService; //导入依赖的package包/类
@Override
protected void doAuth( Intent intent )
{
    final String code = intent.getStringExtra( SitesLoginHandler.VERIFIER_KEY );
    Token accessToken = null;
    String userName = null;
    try
    {
        OAuthService service = new ServiceBuilder()
                .provider( InstagramApi.class )
                .callback( InstagramLoginActivity.CALLBACK_URL )
                .apiKey( InstagramConfig.INSTAGRAM_CLIENT_ID )
                .apiSecret( InstagramConfig.INSTAGRAM_CLIENT_SECRET )
                .scope( InstagramConfig.INSTAGRAM_SCOPE )
                .build();
        accessToken = service.getAccessToken( null, new Verifier( code ) );
        userName = Helper.extractInstagramUserName( accessToken.getRawResponse() );
    }
    catch ( Exception e )
    {
        Helper.debug( "Error while obtaining Instagram access token : " + e.getMessage() );
    }
    boolean success = null != accessToken;
    // Subscriber : InstagramLoginHandler : onInstagramAuthDone()
    HashtaggerApp.bus.post( new InstagramAuthDoneEvent( success, accessToken, userName ) );
}
 
开发者ID:iTwenty,项目名称:Hashtagger,代码行数:27,代码来源:InstagramService.java


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