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


Java OAuth2AccessToken.getScope方法代码示例

本文整理汇总了Java中com.github.scribejava.core.model.OAuth2AccessToken.getScope方法的典型用法代码示例。如果您正苦于以下问题:Java OAuth2AccessToken.getScope方法的具体用法?Java OAuth2AccessToken.getScope怎么用?Java OAuth2AccessToken.getScope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.scribejava.core.model.OAuth2AccessToken的用法示例。


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

示例1: extract

import com.github.scribejava.core.model.OAuth2AccessToken; //导入方法依赖的package包/类
@Override
public OAuth2AccessToken extract(String response) {

    String errorCode = RegexUtil.extractParameter(response, ERRORCODE_REGEX);
    if (errorCode != null) {
        String errorDesc = RegexUtil.extractParameter(response, ERRORDESC_REGEX);
        if (errorDesc != null) {
            errorDesc = errorDesc.replace("+", " ");
        }
        return new GatewayAccessToken(errorCode, errorDesc, response);
    }

    OAuth2AccessToken accessToken = super.extract(response);
    return new GatewayAccessToken(accessToken.getAccessToken(), accessToken.getTokenType()
            , null, null, accessToken.getScope(), response);
}
 
开发者ID:perrywang,项目名称:OAuthGateway,代码行数:17,代码来源:GitHubOAuth2AccessTokenExtractor.java

示例2: extract

import com.github.scribejava.core.model.OAuth2AccessToken; //导入方法依赖的package包/类
@Override
public OAuth2AccessToken extract(String response) {
    String errorCode = RegexUtil.extractParameter(response, ERRORCODE_REGEX);
    if (errorCode != null) {
        String errorDesc = RegexUtil.extractParameter(response, ERRORDESC_REGEX);
        if (errorDesc != null) {
            errorDesc = errorDesc.replace("+", " ");
        }
        return new GatewayAccessToken(errorCode, errorDesc, response);
    }

    OAuth2AccessToken accessToken = super.extract(response);
    return new GatewayAccessToken(accessToken.getAccessToken(), accessToken.getTokenType()
            , accessToken.getExpiresIn(), null, accessToken.getScope(), response);
}
 
开发者ID:perrywang,项目名称:OAuthGateway,代码行数:16,代码来源:FacebookOAuth2AccessTokenExtractor.java

示例3: extract

import com.github.scribejava.core.model.OAuth2AccessToken; //导入方法依赖的package包/类
@Override
public OAuth2AccessToken extract(String response) {
    String errorCode = extractParameter(response, ERRORCODE_REGEX, false);
    if(errorCode != null){
        String errorDesc = extractParameter(response, ERRORDESC_REGEX, false);
        return new GatewayAccessToken(errorCode, errorDesc, response);
    }

    OAuth2AccessToken baseToken = super.extract(response);
    final String userId = extractParameter(response, USERID_REGEX, true);

    return new GatewayAccessToken(baseToken.getAccessToken(), baseToken.getTokenType(), baseToken.getExpiresIn(),
            baseToken.getRefreshToken(), baseToken.getScope(), response, userId);
}
 
开发者ID:perrywang,项目名称:OAuthGateway,代码行数:15,代码来源:WeiboOAuth2AccessTokenJsonExtractor.java

示例4: accessTokenResponse

import com.github.scribejava.core.model.OAuth2AccessToken; //导入方法依赖的package包/类
private WritableMap accessTokenResponse(
  final String providerName,
  final HashMap<String,Object> cfg,
  final OAuth2AccessToken accessToken,
  final String oauthVersion
) {
  WritableMap resp = Arguments.createMap();
  WritableMap response = Arguments.createMap();
  Map accessTokenMap = new Gson().fromJson(accessToken.getRawResponse(), Map.class);

  resp.putString("status", "ok");
  resp.putBoolean("authorized", true);
  resp.putString("provider", providerName);
  try {
    String uuid = (String) accessTokenMap.get("user_id");
    response.putString("uuid", uuid);
  } catch (Exception ex) {
    Log.e(TAG, "Exception while getting the access token");
    ex.printStackTrace();
  }
  
  WritableMap credentials = Arguments.createMap();
  Log.d(TAG, "Credential raw response: " + accessToken.getRawResponse());
  
  credentials.putString("accessToken", accessToken.getAccessToken());
  String authHeader;

  String tokenType = (String) accessTokenMap.get("token_type");
  if (tokenType == null) {
    tokenType = "Bearer";
  }
  
  String scope = accessToken.getScope();
  if (scope == null) {
    scope = (String) cfg.get("scopes");
  }

  String clientID = (String) cfg.get("client_id");
  String idToken = (String) accessTokenMap.get("id_token");

  authHeader = tokenType + " " + accessToken.getAccessToken();
  credentials.putString("authorizationHeader", authHeader);
  credentials.putString("type", tokenType);
  credentials.putString("scopes", scope);
  credentials.putString("clientID", clientID);
  credentials.putString("idToken", idToken);
  response.putMap("credentials", credentials);

  resp.putMap("response", response);

  return resp;
}
 
开发者ID:fullstackreact,项目名称:react-native-oauth,代码行数:53,代码来源:OAuthManagerModule.java


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