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


Java OAuthEncoder类代码示例

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


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

示例1: getAccessTokenExtractor

import org.scribe.utils.OAuthEncoder; //导入依赖的package包/类
@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);
            }
        }
    };
}
 
开发者ID:imotSpot,项目名称:imotSpot,代码行数:22,代码来源:Google2Api.java

示例2: getAccessTokenExtractor

import org.scribe.utils.OAuthEncoder; //导入依赖的package包/类
@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);
            }
        }
    };
}
 
开发者ID:elimu-ai,项目名称:webapp,代码行数:22,代码来源:Google2Api.java

示例3: getAccessTokenExtractor

import org.scribe.utils.OAuthEncoder; //导入依赖的package包/类
@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");
            
            // We are not interested in access_token - we and the JWT encrypted token
            // Matcher matcher = Pattern.compile("\"access_token\" : \"([^&\"]+)\"").matcher(response);
            Matcher matcher = Pattern.compile("\"id_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);
            }
        }
    };
}
 
开发者ID:tahamsaglam,项目名称:duckdns,代码行数:22,代码来源:Google2Api.java

示例4: getAuthorizationUrl

import org.scribe.utils.OAuthEncoder; //导入依赖的package包/类
@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()));
	}
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:17,代码来源:HubicApi.java

示例5: getAccessTokenExtractor

import org.scribe.utils.OAuthEncoder; //导入依赖的package包/类
@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 );
            }
        }
    };
}
 
开发者ID:iTwenty,项目名称:Hashtagger,代码行数:25,代码来源:Google2Api.java

示例6: getAuthorizationUrl

import org.scribe.utils.OAuthEncoder; //导入依赖的package包/类
@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() ) );
    }
}
 
开发者ID:iTwenty,项目名称:Hashtagger,代码行数:17,代码来源:Google2Api.java

示例7: getAuthorizationUrl

import org.scribe.utils.OAuthEncoder; //导入依赖的package包/类
@Override
public String getAuthorizationUrl( OAuthConfig config )
{
    if ( config.hasScope() )
    {
        return String.format( SCOPED_AUTHORIZATION_URL,
                config.getApiKey(),
                OAuthEncoder.encode( config.getCallback() ),
                OAuthEncoder.encode( config.getScope() ) );
    }
    else
    {
        return String.format( AUTHORIZATION_URL,
                config.getApiKey(),
                OAuthEncoder.encode( config.getCallback() ) );
    }
}
 
开发者ID:iTwenty,项目名称:Hashtagger,代码行数:18,代码来源:InstagramApi.java

示例8: getAccessTokenExtractor

import org.scribe.utils.OAuthEncoder; //导入依赖的package包/类
@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);
            }
        }
    };
}
 
开发者ID:kurukurupapa,项目名称:TryAndroid,代码行数:22,代码来源:Google2Api.java

示例9: getAccessTokenExtractor

import org.scribe.utils.OAuthEncoder; //导入依赖的package包/类
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);
            }
        }
    };
}
 
开发者ID:muquit,项目名称:gwtoauthlogindemo,代码行数:21,代码来源:Google2Api.java

示例10: getAuthorizationUrl

import org.scribe.utils.OAuthEncoder; //导入依赖的package包/类
@Override
public String getAuthorizationUrl(OAuthConfig config)
{
    Preconditions.checkValidUrl(config.getCallback(), "Must provide a valid url as callback for Instagram");
    String uuid = ServerUtils.makeRandomString();
    String aUrl = null;
    if (config.hasScope())
    {
        aUrl =  String.format(SCOPED_AUTHORIZATION_URL, config.getApiKey(), OAuthEncoder.encode(config.getCallback()),uuid,OAuthEncoder.encode(config.getScope()));
    }
    else
    {
        aUrl = String.format(AUTHORIZATION_URL, config.getApiKey(), OAuthEncoder.encode(config.getCallback()),uuid);
    }
    logger.info("Autorization URL: " + aUrl);
    return aUrl;
}
 
开发者ID:muquit,项目名称:gwtoauthlogindemo,代码行数:18,代码来源:Linkedin2Api.java

示例11: extractToken

import org.scribe.utils.OAuthEncoder; //导入依赖的package包/类
private static String extractToken(String name, String responseBody) {
    try {
        Preconditions.checkEmptyString(name, "name String is incorrect!");
        Preconditions.checkEmptyString(responseBody, "Response body is incorrect. Can't extract a token from an empty string");
    } catch (IllegalArgumentException e) {
        throw new OAuthException(e.getMessage());
    }

    //{"access_token" : ""}
    String REGEX = "\"%s\"\\s*:\\s*\"([^\"]+)\"";
    REGEX = String.format(REGEX, name);

    Matcher matcher = Pattern.compile(REGEX).matcher(responseBody);
    if (matcher.find()) {
        return OAuthEncoder.decode(matcher.group(1));
    } else {
        throw new OAuthException("Response body is incorrect. Can't extract a token from this: '" + responseBody + "'", null);
    }
}
 
开发者ID:massimozappino,项目名称:tagmycode-java-sdk,代码行数:20,代码来源:TagMyCodeServiceImpl.java

示例12: testAuthorizationWithScopes

import org.scribe.utils.OAuthEncoder; //导入依赖的package包/类
@Test
public void testAuthorizationWithScopes() {
    String state = RandomStringUtils.randomAlphabetic(10);
    String key = RandomStringUtils.randomAlphabetic(10);
    String secret = RandomStringUtils.randomAlphabetic(10);
    LinkedInApi20 api = new LinkedInApi20(state);

    OAuthService service = new ServiceBuilder().provider(api).apiKey(key).apiSecret(secret)
            .callback("http://localhost:4502/linkedin").scope("r_basicprofile,r_emailaddress")
            .build();

    String expected = "https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=" + key
            + "&state=" + state + "&redirect_uri=" + OAuthEncoder.encode("http://localhost:4502/linkedin")
            + "&scope=" + "r_basicprofile%2Cr_emailaddress";

    assertEquals(expected, service.getAuthorizationUrl(null));
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:18,代码来源:LinkedInApi20Test.java

示例13: extract

import org.scribe.utils.OAuthEncoder; //导入依赖的package包/类
private static 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);
    }
}
 
开发者ID:fivef,项目名称:add_to_evernote_note,代码行数:9,代码来源:EvernoteOAuthHelper.java

示例14: getAuthorizationUrl

import org.scribe.utils.OAuthEncoder; //导入依赖的package包/类
@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()));
    }
}
 
开发者ID:imotSpot,项目名称:imotSpot,代码行数:13,代码来源:Google2Api.java

示例15: getAuthorizationUrl

import org.scribe.utils.OAuthEncoder; //导入依赖的package包/类
@Override
public String getAuthorizationUrl(OAuthConfig config) {
    if (config.hasScope()) {
        return String.format(SCOPED_AUTHORIZE_URL, config.getApiKey(), OAuthEncoder.encode(config.getCallback()), githubState, OAuthEncoder.encode(config.getScope()));
    } else {
        return String.format(AUTHORIZE_URL, config.getApiKey(), OAuthEncoder.encode(config.getCallback()), githubState);
    }
}
 
开发者ID:bill1012,项目名称:AdminEAP,代码行数:9,代码来源:GithubApi.java


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