ylbtech-Java-Class-miniprogram:com.common.utils.miniprogram.Auth
1.返回顶部
1.1、
package com.ylbtech.common.utils.miniprogram;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate; /**
* 接口调用凭证
* https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/access-token/auth.getAccessToken.html
*/
public class Auth { /**
* 获取小程序全局唯一后台接口调用凭据(access_token)
* @param appID 小程序唯一凭证,即 AppID,可在「微信公众平台 - 设置 - 开发设置」页中获得。(需要已经成为开发者,且帐号没有异常状态)
* @param secret 小程序唯一凭证密钥,即 AppSecret,获取方式同 appid
* @param restTemplate
* @return
*/
public static String getAccessToken(String appID, String secret, RestTemplate restTemplate) { String accessTokenUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential"; String path = String.format("%s&appid=%s&secret=%s", accessTokenUrl, appID, secret);
ResponseEntity<String> entity = restTemplate.getForEntity(path, String.class);
JSONObject responseObj = JSON.parseObject(entity.getBody());
String access_token = responseObj.getString("access_token"); return access_token;
}
}
1.2、
2.返回顶部
 
3.返回顶部
 
4.返回顶部
 
5.返回顶部
 
 
6.返回顶部
 
作者:ylbtech
出处:http://ylbtech.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

Java-Class-Miniprogram:com.common.utils.miniprogram.Auth的更多相关文章

  1. Java-Class-Miniprogram:com.ylbtech.common.utils.miniprogram.TemplateMessage

    ylbtech-Java-Class-Miniprogram:com.ylbtech.common.utils.miniprogram.TemplateMessage 1.返回顶部 1.1. pack ...

  2. 错误:java.lang.NoClassDefFoundError: com/project/common/exception/ServiceException 的解决

    问题: 项目编译通过,启动报错误信息java.lang.NoClassDefFoundError: com/project/common/exception/ServiceException. 解决方 ...

  3. 异常:Instantiation of bean failed; nested exception is java.lang.NoSuchMethodError: com.google.common.base.Preconditions.che ckState(ZLjava/lang/String;I)V

    Instantiation of bean failed; nested exception is java.lang.NoSuchMethodError: com.google.common.bas ...

  4. elasticsearch client 为空 错误信息:java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecut‌​or()Ljava/util/concu‌​rrent/Executor

    错误信息:java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecut‌​or() ...

  5. 关于ActiveMQ+Zookeeper做集群时,解决启动报错:java.io.IOException: com/google/common/util/concurrent/internal/InternalFutureFailureAccess

    这个问题我也是无意间碰到的,之前一直是使用单机的ActiveMQ,所以也没这个问题,但是做集群时碰到这个问题,问题是这样子出现的: 首先,我准备了三台虚拟机,然后使用 Replicated Level ...

  6. Hive启动报错:java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument

    报错详细: Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preco ...

  7. 出现java.lang.NoClassDefFoundError: com/google/common/base/Charsets异常错误

    使用selenium,出现java.lang.NoClassDefFoundError: com/google/common/base/Charsets异常错误 原因:selenium-server- ...

  8. java.lang.NoSuchMethodError: com.google.common.collect.Maps.newConcurrentMap()Ljava/util/concurrent/Concurren‌​tMap;

    在storm启动topo的时候,报错: java.lang.NoSuchMethodError: com.google.common.collect.Maps.newConcurrentMap()Lj ...

  9. Selenium 运行时出现错误(java.lang.NoClassDefFoundError: com/google/common/base/Function)

    已经写好了java脚本,点击运行的过程中如果出现如下的错误提示时: java.lang.NoClassDefFoundError: com/google/common/base/Function 问题 ...

随机推荐

  1. 编程算法 - 求1+2+...+n(函数继承) 代码(C++)

    求1+2+...+n(函数继承) 代码(C++) 本文地址: http://blog.csdn.net/caroline_wendy 题目: 求1+2+...+n, 要求不能使用乘除法\for\whi ...

  2. struct结构体在c和c++中的差别

    非常多次遇到这个struct的问题,今天在这里简单总结一下我的理解 一.struct在C 中的使用 1.单独使用struct定义结构体类型 struct Student { int id; int n ...

  3. LeetCode 8. String to Integer (atoi) (字符串到整数)

    Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. ...

  4. SpringBoot之Web开发——webjars&静态资源映射规则

    在webjars中找到需要引入的Maven依赖,添加到pom.xml中,即可自动导入相关依赖.

  5. ERROR (ConnectionError): HTTPConnectionPool (Caused by &lt;class &#39;socket.error&#39;&gt;: [Errno 111] Connecti

    感谢朋友支持本博客.欢迎共同探讨交流,因为能力和时间有限,错误之处在所难免.欢迎指正! 假设转载,请保留作者信息. 博客地址:http://blog.csdn.net/qq_21398167 原博文地 ...

  6. The bytes/str dichotomy in Python 3

    The bytes/str dichotomy in Python 3 - Eli Bendersky's website https://eli.thegreenplace.net/2012/01/ ...

  7. Android 自带Base64加密解密

    Android项目引用不到以下两个java类 import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; Android有自己的base ...

  8. UVALive 4671 K-neighbor substrings 巧用FFT

    UVALive4671   K-neighbor substrings   给定一个两个字符串A和B B为模式串.问A中有多少不同子串与B的距离小于k 所谓距离就是不同位的个数. 由于字符串只包含a和 ...

  9. nginx搭建基于http协议的视频点播服务器

    1,于由自己的服务器上已经安装好nginx(具体安装方法见我的另一篇文章,Linux中安装nginx),所以不再安装. 2,下载nginx_mod_h264_streaming-2.2.7.tar.g ...

  10. Android Jetpack - 使用 Navigation 管理页面跳转

    在今年的 IO 大会上,发布了一套叫 Android Jetpack 的程序库.Android Jetpack 里的组件大部分我们都接触过了,其中也有一些全新的组件,其中一个就是 Navigation ...