me.chanjar.weixin.mp.api.WxMpService.oauth2buildAuthorizationUrl()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(407)

本文整理了Java中me.chanjar.weixin.mp.api.WxMpService.oauth2buildAuthorizationUrl()方法的一些代码示例,展示了WxMpService.oauth2buildAuthorizationUrl()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WxMpService.oauth2buildAuthorizationUrl()方法的具体详情如下:
包路径:me.chanjar.weixin.mp.api.WxMpService
类名称:WxMpService
方法名:oauth2buildAuthorizationUrl

WxMpService.oauth2buildAuthorizationUrl介绍

[英]```
构造oauth2授权的url连接
详情请见: http://mp.weixin.qq.com/wiki/index.php?title=网页授权获取用户基本信息

[中]```
构造oauth2授权的url连接 
详情请见: http://mp.weixin.qq.com/wiki/index.php?title=网页授权获取用户基本信息

代码示例

代码示例来源:origin: com.github.hippoom/wechat-mp-autoconfigure

@RequestMapping(value = "/wechat/oauth/authorize", method = GET)
protected void askWeChatWhoTheUserIs(@RequestParam(name = "origin") String origin,
  HttpServletRequest request,
  HttpServletResponse response) throws IOException {
  final String endpointUrl = String.format("%s/wechat/oauth/token", appBaseUri);
  final String base64EncodedOrigin =
    Base64.getUrlEncoder().encodeToString(origin.getBytes(Charset.forName("UTF-8")));
  final String redirect = weChatMpService
    .oauth2buildAuthorizationUrl(endpointUrl, "snsapi_base", base64EncodedOrigin);
  log.debug("We don't know who u are, redirecting you from {} to {}", origin, redirect);
  response.sendRedirect(redirect);
}

代码示例来源:origin: sqmax/springboot-project

@GetMapping("/authorize")
  public String authorize(@RequestParam("returnUrl") String returnUrl){
//        WxMpService wxMpService=new WxMpServiceImpl();
    //1. 配置
    //2.调用方法
    String url=projectUrlConfig.getWechatMpAuthorize()+"/sell/wechat/userInfo";
    String redirectUrl=wxMpService.oauth2buildAuthorizationUrl(url,WxConsts.OAUTH2_SCOPE_BASE, URLEncoder.encode(returnUrl));
    log.info("【微信网页授权】获取code,redirectUrl={}",redirectUrl);
    return "redirect:"+redirectUrl;//重定向到下面一个方法
  }
  @GetMapping("/userInfo")

代码示例来源:origin: linxinzhe/java-springboot-sell

@GetMapping("/authorize")
public String authorize(@RequestParam("returnUrl") String returnUrl) {
  //1.配置
  //2.调用方法
  String url = projectUrlConfig.getWechatMpAuthorize() + "/sell/wechat/userInfo";
  String redirectUrl = wxMpService.oauth2buildAuthorizationUrl(url, WxConsts.OAUTH2_SCOPE_BASE, URLEncoder.encode(returnUrl));
  log.info("【微信网页授权】获取code,result={}", redirectUrl);
  return "redirect:" + redirectUrl;
}

代码示例来源:origin: aillamsun/genesis

/**
 * @param @param  oauthType
 * @param @param  paramData
 * @param @return 参数
 * @return String    返回类型
 * @throws UnsupportedEncodingException
 * @throws
 * @Title: oauth2
 * @Description: TODO   获取授权的 URL ,用来重定向到微信的授权接口
 */
public static String oauth2(String oauthType, String paramData, String oauthRtnSuccUrl) throws UnsupportedEncodingException {
  WxMpService wxMpService = WxMpServiceFactory.getWxMpService();
  //如果没有传入 则取 当时 配置的 授权地址
  if (StringUtils.isBlank(oauthRtnSuccUrl)) {
    oauthRtnSuccUrl = WxMpServiceFactory.getConfig().getOauth2redirectUri();
  }
  return wxMpService.oauth2buildAuthorizationUrl(
      oauthRtnSuccUrl, StringUtils.isNotBlank(oauthType) ? oauthType : WxConsts.OAUTH2_SCOPE_BASE, URLEncoder.encode(paramData, "utf-8"));
}

代码示例来源:origin: liuweijw/fw-cloud-framework

urlInfoService.cacheUrlInfo(urlInfoBean);
String redirectURL = wxService.oauth2buildAuthorizationUrl(
    returnUrl,
    from.intValue() == 1 ? WxConsts.OAuth2Scope.SNSAPI_BASE

代码示例来源:origin: binarywang/weixin-java-mp-demo-springboot

URL requestURL = new URL(request.getRequestURL().toString());
String url = WxMpConfiguration.getMpServices().get(appid)
  .oauth2buildAuthorizationUrl(
    String.format("%s://%s/wx/redirect/%s/greet", requestURL.getProtocol(), requestURL.getHost(), appid),
    WxConsts.OAuth2Scope.SNSAPI_USERINFO, null);

相关文章