本文整理汇总了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());
}
};
}
示例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());
}
};
}
示例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());
}
};
}
示例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() );
}
};
}