org.scribe.model.OAuthConfig Java Examples

The following examples show how to use org.scribe.model.OAuthConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseOAuth2Api.java    From jerseyoauth2 with MIT License 6 votes vote down vote up
@Override
public final String getAuthorizationUrl(OAuthConfig config) {
	ParameterList paramList = new ParameterList();
	if (state!=null) {
		paramList.add("state", state);
	}
	paramList.add("response_type", getResponseType());
	paramList.add("client_id", config.getApiKey());
	if (StringUtils.isNotEmpty(config.getCallback()) && 
		!OAuthConstants.OUT_OF_BAND.equals(config.getCallback())) {
		paramList.add("redirect_uri", config.getCallback()); // for implicit grant
	}
	if (StringUtils.isNotEmpty(config.getScope())) {
		paramList.add("scope", config.getScope());
	}
	return paramList.appendTo(getAuthorizationUrlBase());
}
 
Example #2
Source File: HubicApi.java    From swift-explorer with Apache License 2.0 6 votes vote down vote up
@Override
public String getAuthorizationUrl(OAuthConfig config) 
{
	Preconditions.checkValidUrl(config.getCallback(), "Must provide a valid url as callback.") ;
	if (config.hasScope()) 
	{
		return String.format(SCOPED_AUTHORIZE_URL, config.getApiKey(),
				OAuthEncoder.encode(config.getCallback()),
				OAuthEncoder.encode(config.getScope()));
	} 
	else 
	{
		return String.format(AUTHORIZE_URL, config.getApiKey(),
				OAuthEncoder.encode(config.getCallback()));
	}
}
 
Example #3
Source File: Google2Api.java    From jpa-invoicer with The Unlicense 5 votes vote down vote up
@Override
public String getAuthorizationUrl(OAuthConfig config) {
    // Append scope if present
    if (config.hasScope()) {
        return String.format(SCOPED_AUTHORIZE_URL, config.getApiKey(),
                OAuthEncoder.encode(config.getCallback()),
                OAuthEncoder.encode(config.getScope()));
    } else {
        return String.format(AUTHORIZE_URL, config.getApiKey(),
                OAuthEncoder.encode(config.getCallback()));
    }
}
 
Example #4
Source File: SliApi.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
@Override
public String getAuthorizationUrl(OAuthConfig config) {
    Preconditions.checkValidUrl(config.getCallback(), "Must provide a valid url as callback.");

    return String.format(REQUEST_TOKEN_FRAGMENT, apiUrl.toString(), config.getApiKey(),
            OAuthEncoder.encode(config.getCallback()));
}
 
Example #5
Source File: OAuth2ServiceWrapper.java    From jerseyoauth2 with MIT License 4 votes vote down vote up
public OAuth2ServiceWrapper(OAuthService wrapped, DefaultApi20 api, OAuthConfig config)
{
	this.wrapped = wrapped;
	this.api = api;
	this.config = config;
}
 
Example #6
Source File: WeiXinOAuth20ServiceImpl.java    From cas4.0.x-server-wechat with Apache License 2.0 4 votes vote down vote up
public WeiXinOAuth20ServiceImpl(DefaultApi20 api, OAuthConfig config, int connectTimeout, int readTimeout, String proxyHost, int proxyPort) {
    super(api, config, connectTimeout, readTimeout, proxyHost, proxyPort);
}
 
Example #7
Source File: BaseOAuth2Api.java    From jerseyoauth2 with MIT License 4 votes vote down vote up
@Override
public OAuthService createService(OAuthConfig config) {
	return new OAuth2ServiceWrapper(super.createService(config), this, config);
}
 
Example #8
Source File: SliApi.java    From secure-data-service with Apache License 2.0 4 votes vote down vote up
public SLIOauth20ServiceImpl(DefaultApi20 api, OAuthConfig config) {
    super(api, config);
    myApi = api;
    myConfig = config;
}
 
Example #9
Source File: SliApi.java    From secure-data-service with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public OAuthService createService(OAuthConfig config) {
    return new SLIOauth20ServiceImpl(this, config);
}
 
Example #10
Source File: SliApi.java    From secure-data-service with Apache License 2.0 4 votes vote down vote up
@Override
public String getAuthorizationUrl(OAuthConfig config) {
    Preconditions.checkValidUrl(config.getCallback(), "Must provide a valid url as callback.");
    
    return String.format(authorizeUrl, config.getApiKey(), OAuthEncoder.encode(config.getCallback()));
}
 
Example #11
Source File: HubicApi.java    From swift-explorer with Apache License 2.0 4 votes vote down vote up
@Override
public OAuthService createService(OAuthConfig config)
{
	return new HubicOAuth20ServiceImpl(this, config);
}
 
Example #12
Source File: HubicOAuth20ServiceImpl.java    From swift-explorer with Apache License 2.0 4 votes vote down vote up
public HubicOAuth20ServiceImpl(HubicApi api, OAuthConfig config) {
	this.api = api;
	this.config = config;
}
 
Example #13
Source File: Google2Api.java    From jpa-invoicer with The Unlicense 4 votes vote down vote up
public GoogleOAuth2Service(DefaultApi20 api, OAuthConfig config) {
    super(api, config);
    this.api = api;
    this.config = config;
}
 
Example #14
Source File: Google2Api.java    From jpa-invoicer with The Unlicense 4 votes vote down vote up
@Override
public OAuthService createService(OAuthConfig config) {
    return new GoogleOAuth2Service(this, config);
}
 
Example #15
Source File: BitbucketApi.java    From bitbucket-build-status-notifier-plugin with MIT License 4 votes vote down vote up
@Override
public OAuthService createService(OAuthConfig config) {
    return new BitbucketApiService(this, config);
}
 
Example #16
Source File: BitbucketApi.java    From bitbucket-build-status-notifier-plugin with MIT License 4 votes vote down vote up
@Override
public String getAuthorizationUrl(OAuthConfig config) {
    return OAUTH_ENDPOINT + "authorize";
}
 
Example #17
Source File: WeiXinClient.java    From cas4.0.x-server-wechat with Apache License 2.0 4 votes vote down vote up
protected void internalInit() {
super.internalInit();
//String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_userinfo#wechat_redirect";
WeiXinApi20 api = new WeiXinApi20();
this.service = new WeiXinOAuth20ServiceImpl(api, new OAuthConfig(this.key, this.secret, this.callbackUrl, SignatureType.Header, null, null),
        this.connectTimeout, this.readTimeout, this.proxyHost, this.proxyPort);    }
 
Example #18
Source File: WeiXinApi20.java    From cas4.0.x-server-wechat with Apache License 2.0 4 votes vote down vote up
@Override
public String getAuthorizationUrl(OAuthConfig config) {
    return String.format(url, config.getApiKey(), OAuthEncoder.encode("http://conference.3audit.com/cas-server/login"));
}
 
Example #19
Source File: WeiXinClientOauth.java    From cas4.0.x-server-wechat with Apache License 2.0 4 votes vote down vote up
protected void internalInit() {
super.internalInit();
String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_userinfo&state=WeiXinClientOauth#wechat_redirect";
WeiXinApi20 api = new WeiXinApi20(url);
this.service = new WeiXinOAuth20ServiceImpl(api, new OAuthConfig(this.key, this.secret, this.callbackUrl, SignatureType.Header, null, null),
        this.connectTimeout, this.readTimeout, this.proxyHost, this.proxyPort);    }
 
Example #20
Source File: BasicRESTClient.java    From secure-data-service with Apache License 2.0 3 votes vote down vote up
/**
 *
 * Construct a new RESTClient instance.
 *
 * @param apiServerURL
 *            Fully qualified URL to the root of the API server.
 *
 * @param clientId
 *            Unique client identifier for this application.
 *
 * @param clientSecret
 *            Unique client secret value for this application.
 *
 * @param callbackURL
 *            URL used to redirect after authentication.
 */

public BasicRESTClient(final URL apiServerURL, final String clientId, final String clientSecret,
        final URL callbackURL) {

    client = ClientFactory.newClient();

    apiServerUri = apiServerURL.toString().endsWith("/") ? apiServerURL.toString() + PathConstants.API_SERVER_PATH
            : apiServerURL.toString() + "/" + PathConstants.API_SERVER_PATH;

    sliApi = new SliApi();
    SliApi.setBaseUrl(apiServerURL);
    config = new OAuthConfig(clientId, clientSecret, callbackURL.toString(), null, null, null);
}