Java Code Examples for org.scribe.model.OAuthConfig

The following examples show how to use org.scribe.model.OAuthConfig. These examples are extracted from open source projects. 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 Project: swift-explorer   Source File: HubicApi.java    License: 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 2
Source Project: jerseyoauth2   Source File: BaseOAuth2Api.java    License: 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 3
Source Project: jpa-invoicer   Source File: Google2Api.java    License: 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 Project: secure-data-service   Source File: SliApi.java    License: 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
public WeiXinOAuth20ServiceImpl(DefaultApi20 api, OAuthConfig config, int connectTimeout, int readTimeout, String proxyHost, int proxyPort) {
    super(api, config, connectTimeout, readTimeout, proxyHost, proxyPort);
}
 
Example 6
Source Project: cas4.0.x-server-wechat   Source File: WeiXinClientOauth.java    License: 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 7
Source Project: cas4.0.x-server-wechat   Source File: WeiXinApi20.java    License: 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 8
Source Project: cas4.0.x-server-wechat   Source File: WeiXinClient.java    License: 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 9
@Override
public String getAuthorizationUrl(OAuthConfig config) {
    return OAUTH_ENDPOINT + "authorize";
}
 
Example 10
@Override
public OAuthService createService(OAuthConfig config) {
    return new BitbucketApiService(this, config);
}
 
Example 11
Source Project: jpa-invoicer   Source File: Google2Api.java    License: The Unlicense 4 votes vote down vote up
@Override
public OAuthService createService(OAuthConfig config) {
    return new GoogleOAuth2Service(this, config);
}
 
Example 12
Source Project: jpa-invoicer   Source File: Google2Api.java    License: The Unlicense 4 votes vote down vote up
public GoogleOAuth2Service(DefaultApi20 api, OAuthConfig config) {
    super(api, config);
    this.api = api;
    this.config = config;
}
 
Example 13
Source Project: swift-explorer   Source File: HubicOAuth20ServiceImpl.java    License: Apache License 2.0 4 votes vote down vote up
public HubicOAuth20ServiceImpl(HubicApi api, OAuthConfig config) {
	this.api = api;
	this.config = config;
}
 
Example 14
Source Project: swift-explorer   Source File: HubicApi.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public OAuthService createService(OAuthConfig config)
{
	return new HubicOAuth20ServiceImpl(this, config);
}
 
Example 15
Source Project: secure-data-service   Source File: SliApi.java    License: 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 16
Source Project: secure-data-service   Source File: SliApi.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public OAuthService createService(OAuthConfig config) {
    return new SLIOauth20ServiceImpl(this, config);
}
 
Example 17
Source Project: secure-data-service   Source File: SliApi.java    License: Apache License 2.0 4 votes vote down vote up
public SLIOauth20ServiceImpl(DefaultApi20 api, OAuthConfig config) {
    super(api, config);
    myApi = api;
    myConfig = config;
}
 
Example 18
Source Project: jerseyoauth2   Source File: BaseOAuth2Api.java    License: MIT License 4 votes vote down vote up
@Override
public OAuthService createService(OAuthConfig config) {
	return new OAuth2ServiceWrapper(super.createService(config), this, config);
}
 
Example 19
Source Project: jerseyoauth2   Source File: OAuth2ServiceWrapper.java    License: 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 20
Source Project: secure-data-service   Source File: BasicRESTClient.java    License: 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);
}