Java Code Examples for org.scribe.utils.OAuthEncoder

The following examples show how to use org.scribe.utils.OAuthEncoder. 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: jpa-invoicer   Source File: Google2Api.java    License: The Unlicense 6 votes vote down vote up
@Override
public AccessTokenExtractor getAccessTokenExtractor() {
    return new AccessTokenExtractor() {
        
        @Override
        public Token extract(String response) {
            Preconditions.checkEmptyString(response, "Response body is incorrect. Can't extract a token from an empty string");
 
            Matcher matcher = Pattern.compile("\"access_token\" : \"([^&\"]+)\"").matcher(response);
            if (matcher.find())
            {
              String token = OAuthEncoder.decode(matcher.group(1));
              return new Token(token, "", response);
            } 
            else
            {
              throw new OAuthException("Response body is incorrect. Can't extract a token from this: '" + response + "'", null);
            }
        }
    };
}
 
Example 2
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 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
Source Project: EverMemo   Source File: EvernoteAuthToken.java    License: MIT License 5 votes vote down vote up
private String extract(String response, Pattern p) {
  Matcher matcher = p.matcher(response);
  if (matcher.find() && matcher.groupCount() >= 1) {
    return OAuthEncoder.decode(matcher.group(1));
  } else {
    throw new OAuthException("Response body is incorrect. " +
        "Can't extract token and secret from this: '" + response + "'", null);
  }
}
 
Example 6
Source Project: EverMemo-EverNote   Source File: EvernoteAuthToken.java    License: MIT License 5 votes vote down vote up
private String extract(String response, Pattern p) {
  Matcher matcher = p.matcher(response);
  if (matcher.find() && matcher.groupCount() >= 1) {
    return OAuthEncoder.decode(matcher.group(1));
  } else {
    throw new OAuthException("Response body is incorrect. " +
        "Can't extract token and secret from this: '" + response + "'", null);
  }
}
 
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: 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()));
}