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


Java OAuth20ServiceImpl类代码示例

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


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

示例1: createService

import org.scribe.oauth.OAuth20ServiceImpl; //导入依赖的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

示例2: createService

import org.scribe.oauth.OAuth20ServiceImpl; //导入依赖的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

示例3: createService

import org.scribe.oauth.OAuth20ServiceImpl; //导入依赖的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

示例4: createService

import org.scribe.oauth.OAuth20ServiceImpl; //导入依赖的package包/类
/**
 * Not sure if it's a Scribe bug or an Instagram oddity. We have to send the
 * various parameters in the POST body (Scribe sends them as query string)
 * and we must include the 'grant_type'.
 */
@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( "grant_type", "authorization_code" );
            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() );

            if ( config.hasScope() )
            {
                request.addBodyParameter( OAuthConstants.SCOPE, config.getScope() );
            }

            Response response = request.send();
            return getAccessTokenExtractor().extract( response.getBody() );
        }
    };
}
 
开发者ID:iTwenty,项目名称:Hashtagger,代码行数:32,代码来源:InstagramApi.java


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