org.springframework.social.oauth2.TokenStrategy Java Examples
The following examples show how to use
org.springframework.social.oauth2.TokenStrategy.
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: QQImpl.java From cola with MIT License | 5 votes |
/** * 构造方法获取openId */ public QQImpl(String accessToken, String appId) { //access_token作为查询参数来携带。 super(accessToken, TokenStrategy.ACCESS_TOKEN_PARAMETER); this.appId = appId; String url = String.format(QQ_URL_GET_OPENID, accessToken); String result = getRestTemplate().getForObject(url, String.class); log.info("【QQImpl】 QQ_URL_GET_OPENID={} result={}", url, result); this.openId = StringUtils.substringBetween(result, "\"openid\":\"", "\"}"); }
Example #2
Source File: QQImpl.java From pre with GNU General Public License v3.0 | 5 votes |
public QQImpl(String accessToken, String appid) { //将token作为查询参数 super(accessToken, TokenStrategy.ACCESS_TOKEN_PARAMETER); this.appid = appid; //拼接成最终的openid的请求地址 String url = String.format(URL_GET_OPENID, accessToken); String result = getRestTemplate().getForObject(url, String.class); this.openid = StringUtils.substringBetween(result, "\"openid\":\"", "\"}"); }
Example #3
Source File: QQImpl.java From FEBS-Security with Apache License 2.0 | 5 votes |
public QQImpl(String accessToken, String appId) { super(accessToken, TokenStrategy.ACCESS_TOKEN_PARAMETER); this.appId = appId; String url = String.format(FebsConstant.GET_QQ_OPEN_ID_URL, accessToken); String result = this.getRestTemplate().getForObject(url, String.class); log.info(result); this.openId = StringUtils.substringBetween(result, "\"openid\":\"", "\"}"); }
Example #4
Source File: OAuth2CredentialProviderFactory.java From syndesis with Apache License 2.0 | 5 votes |
@Override public CredentialProvider create(final SocialProperties properties) { if (properties instanceof UnconfiguredProperties) { return new OAuth2CredentialProvider<>(OAUTH_2); } if (!(properties instanceof OAuth2ConnectorProperties)) { throw new IllegalArgumentException(String.format("Unsupported social properties instance - " + "expected properties of type %s, but found %s", OAuth2ConnectorProperties.class, properties.getClass())); } final OAuth2ConnectorProperties oauth2Properties = (OAuth2ConnectorProperties) properties; final String appId = oauth2Properties.getAppId(); final String appSecret = oauth2Properties.getAppSecret(); final String authorizationUrl = oauth2Properties.getAuthorizationUrl(); final String authenticationUrl = oauth2Properties.getAuthenticationUrl(); final String accessTokenUrl = oauth2Properties.getAccessTokenUrl(); final boolean useParametersForClientCredentials = oauth2Properties.isUseParametersForClientCredentials(); final TokenStrategy tokenStrategy = oauth2Properties.getTokenStrategy(); final String scope = oauth2Properties.getScope(); final OAuth2ServiceProvider<RestOperations> serviceProvider = new GenericOAuth2ServiceProvider(appId, appSecret, authorizationUrl, authenticationUrl, accessTokenUrl, useParametersForClientCredentials, tokenStrategy); final OAuth2ConnectionFactory<RestOperations> connectionFactory = new OAuth2ConnectionFactory<>(OAUTH_2, serviceProvider, null); connectionFactory.setScope(scope); final OAuth2Applicator applicator = new OAuth2Applicator(properties); applicator.setAccessTokenProperty("accessToken"); applicator.setAccessTokenExpiresAtProperty("accessTokenExpiresAt"); applicator.setRefreshTokenProperty("refreshToken"); applicator.setClientIdProperty("clientId"); applicator.setClientSecretProperty("clientSecret"); return new OAuth2CredentialProvider<>(OAUTH_2, connectionFactory, applicator, oauth2Properties.getAdditionalQueryParameters()); }
Example #5
Source File: OAuth2ConnectorProperties.java From syndesis with Apache License 2.0 | 5 votes |
public OAuth2ConnectorProperties(final Connector connector) { super(connector); accessTokenUrl = requiredProperty(connector, Credentials.ACCESS_TOKEN_URL_TAG); authenticationUrl = optionalProperty(connector, Credentials.AUTHENTICATION_URL_TAG).orElse(null); authorizationUrl = requiredProperty(connector, Credentials.AUTHORIZATION_URL_TAG); tokenStrategy = optionalProperty(connector, Credentials.TOKEN_STRATEGY_TAG).map(TokenStrategy::valueOf) .orElse(TokenStrategy.AUTHORIZATION_HEADER); useParameters = optionalProperty(connector, Credentials.AUTHORIZE_USING_PARAMETERS_TAG).map(Boolean::valueOf).orElse(false); scope = optionalProperty(connector, Credentials.SCOPE_TAG).orElse(null); additionalQueryParameters = optionalProperty(connector, Credentials.ADDITIONAL_QUERY_PARAMETERS_TAG) .map(params -> readJsonMap(params)) .orElse(Collections.emptyMap()); }
Example #6
Source File: WechatImpl.java From cola with MIT License | 4 votes |
public WechatImpl(String accessToken) { super(accessToken, TokenStrategy.ACCESS_TOKEN_PARAMETER); }
Example #7
Source File: WechatMpImpl.java From cola with MIT License | 4 votes |
public WechatMpImpl(String accessToken) { super(accessToken, TokenStrategy.ACCESS_TOKEN_PARAMETER); }
Example #8
Source File: WeiXinImpl.java From pre with GNU General Public License v3.0 | 4 votes |
public WeiXinImpl(String accessToken) { super(accessToken, TokenStrategy.ACCESS_TOKEN_PARAMETER); }
Example #9
Source File: WechatImpl.java From spring-social-wechat with Apache License 2.0 | 4 votes |
public WechatImpl(String accessToken) { super(accessToken, TokenStrategy.ACCESS_TOKEN_PARAMETER); userOperations = new UserTemplate(restOperations(), accessToken); }
Example #10
Source File: WeiXinImpl.java From FEBS-Security with Apache License 2.0 | 4 votes |
public WeiXinImpl(String accessToken) { super(accessToken, TokenStrategy.ACCESS_TOKEN_PARAMETER); }
Example #11
Source File: OAuth2ConnectorProperties.java From syndesis with Apache License 2.0 | 4 votes |
public TokenStrategy getTokenStrategy() { return tokenStrategy; }
Example #12
Source File: QQImpl.java From paascloud-master with Apache License 2.0 | 3 votes |
/** * Instantiates a new Qq. * * @param accessToken the access token * @param appId the app id */ public QQImpl(String accessToken, String appId) { super(accessToken, TokenStrategy.ACCESS_TOKEN_PARAMETER); this.appId = appId; String url = String.format(URL_GET_OPENID, accessToken); String result = getRestTemplate().getForObject(url, String.class); log.info("result={}", result); this.openId = StringUtils.substringBetween(result, "\"openid\":\"", "\"}"); }
Example #13
Source File: WeixinImpl.java From paascloud-master with Apache License 2.0 | 2 votes |
/** * Instantiates a new Weixin. * * @param accessToken the access token */ public WeixinImpl(String accessToken) { super(accessToken, TokenStrategy.ACCESS_TOKEN_PARAMETER); }