xxxxxxxxxxxxxxxxxxxxxxxxxxxx

Get Authorization code:
Request:
https://accounts.google.com/o/oauth2/v2/auth
?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground
&prompt=consent
&response_type=code
&client_id=407408718192.apps.googleusercontent.com
&scope=https%3A%2F%2Fmail.google.com
&access_type=offline

Response:
GET /oauthplayground/
?code=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
&scope=https://mail.google.com HTTP/1.1
Host: developers.google.com


Get Accesstoken:
Request:
POST /oauth2/v4/token HTTP/1.1
Host: www.googleapis.com
Content-length: 277
content-type: application/x-www-form-urlencoded
user-agent: google-oauth-playground
code=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
&redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground
&client_id=407408718192.apps.googleusercontent.com
&client_secret=************
&scope=
&grant_type=authorization_code

Response:
HTTP/1.1 200 OK
Content-length: 583
X-xss-protection: 1; mode=block
X-content-type-options: nosniff
Transfer-encoding: chunked
Vary: Origin, X-Origin, Referer
Server: ESF
-content-encoding: gzip
Cache-control: private
Date: Fri, 15 Mar 2019 06:36:45 GMT
X-frame-options: SAMEORIGIN
Alt-svc: quic=":443"; ma=2592000; v="46,44,43,39"
Content-type: application/json; charset=utf-8
{
  "access_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "scope": "https://www.googleapis.com/auth/gmail",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}

转载于:https://www.cnblogs.com/joyo-w/p/10660025.html

微信小程序解密并获取手机号的过程可以通过以下步骤实现: 1. 在小程序端,用户点击授权获取手机号的按钮,触发相应的事件。 2. 小程序调用`wx.login`接口获取临时登录凭证code。 3. 小程序调用`wx.getUserInfo`接口获取用户信息,其中包括加密的手机号信息。 4. 小程序将获取到的code和加密的手机号信息发送给后端服务器。 5. 后端服务器使用微信提供的解密算法对加密的手机号进行解密。在Java中,可以使用`javax.crypto`包下的相关类来实现解密操作。 6. 解密后的手机号可以用于后续的业务逻辑处理。 下面是一个示例代码,演示了如何在Java中解密微信小程序的手机号: ```java import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import java.util.Base64; public class WeChatPhoneNumberDecryptor { public static String decryptPhoneNumber(String sessionKey, String encryptedData, String iv) throws Exception { byte[] sessionKeyBytes = Base64.getDecoder().decode(sessionKey); byte[] encryptedDataBytes = Base64.getDecoder().decode(encryptedData); byte[] ivBytes = Base64.getDecoder().decode(iv); SecretKeySpec secretKeySpec = new SecretKeySpec(sessionKeyBytes, "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); IvParameterSpec ivParameterSpec = new IvParameterSpec(ivBytes); cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec); byte[] decryptedDataBytes = cipher.doFinal(encryptedDataBytes); return new String(decryptedDataBytes); } public static void main(String[] args) { String sessionKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"; String encryptedData = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"; String iv = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"; try { String phoneNumber = decryptPhoneNumber(sessionKey, encryptedData, iv); System.out.println("Decrypted phone number: " + phoneNumber); } catch (Exception e) { e.printStackTrace(); } } } ``` 请注意,上述代码中的`sessionKey`、`encryptedData`和`iv`需要替换为实际的值。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值