One-Tap Login API
Functional description
Submit loginToken, then returns the encrypted cell phone number.
Call Address
Android、Harmony、iOS Use
POST https://api.verification.jpush.cn/v1/web/loginTokenVerify
Web Use
POST https://api.verification.jpush.cn/v1/web/h5/loginTokenVerify
Call Authentication
See for more information REST API Overview Authentication Note.
Example request
curl --insecure -X POST -v https://api.verification.jpush.cn/v1/web/loginTokenVerify -H "Content-Type: application/json" -u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1" -d '{
"loginToken": "STsid0000001542695429579Ob28vB7b0cYTI9w0GGZrv8ujUu05qZvw",
"exID": "1234566"
}'
** Request parameters**
| Keyword | Type | Options | Meaning |
|---|---|---|---|
| loginToken | String | Required | Authentication SDK Received loginToken |
| exID | String | Optional | Developer custom id, not required |
Response Example
Request succeeded
{
"id": 117270465679982592,
"code": 8000,
"content": "get phone success",
"exID": "1234566",
"phone": "HpBLIQ/6SkFl0pAq0LMdw1aZ8RHoofgWmaY//LE+0ahkSdHC5oTCnjrR8Tj8y5naKVI03torFU+EzAQnwtVqAoQyYckT0S3Q02TKuAal3VRGiR5Lmp4g2A5Mh4/W5A4o6QFviHuBVJZE/WV0AzU5w4NGhpyQntOeF0UyovYATy4="
}
** Request failed**
{
"code": 8001,
"content": "get phone fail"
}
** Response parameters**
| Keyword | Type | Meaning |
|---|---|---|
| id | Long | Drift. Could be empty if the request goes wrong. |
| exID | String | Developer custom id if request is empty |
| code | Integer | Return Code |
| content | String | Response Code Reference |
| phone | String | Encrypted cell phone number.Jiguang Example of parsed cell phone number: Continental number:13812345678;Hong Kong mobile number:+852-12345678 |
RSA Example of private key decryption
1024‑bit / PKCS#1 v1.5
Java
import javax.crypto.Cipher;
import java.nio.charset.StandardCharsets;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Base64;
public class RSADecrypt {public static void main(String[] args) throws Exception {String encrypted = args[0];
String prikey = args[1];
String result = decrypt(encrypted, prikey);
System.out.println(result);
}
public static String decrypt(String cryptograph, String prikey) throws Exception {PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(Base64.getDecoder().decode(prikey));
PrivateKey privateKey = KeyFactory.getInstance("RSA").generatePrivate(keySpec);
Cipher cipher=Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.DECRYPT_MODE, privateKey);
byte [] b = Base64.getDecoder().decode(cryptograph);
return new String(cipher.doFinal(b), StandardCharsets.UTF_8);
}
}
Python
You need to install pycryptodome first:
pip install pycryptodome
#!/usr/bin/env python3
import base64
import sys
from Crypto.Cipher import PKCS1_v1_5
from Crypto.PublicKey import RSA
PREFIX = "-----BEGIN PRIVATE KEY-----"
SUFFIX = "-----END PRIVATE KEY-----"
encrypted = sys.argv[1]
prikey = sys.argv[2]
key = "{}\n{}\n{}".format(PREFIX, prikey, SUFFIX)
private_key = RSA.import_key(key)
cipher = PKCS1_v1_5.new(private_key)
sentinel = b""
result = cipher.decrypt(base64.b64decode(encrypted), sentinel)
if result == sentinel:
raise ValueError("decrypt failed")
print(result.decode("utf-8"))
PHP
<?php
$prefix = '-----BEGIN PRIVATE KEY-----';
$suffix = '-----END PRIVATE KEY-----';
$encrypted = $argv[1];
$prikey = $argv[2];
$key = $prefix . "\n" . $prikey . "\n" . $suffix;
$success = openssl_private_decrypt(
base64_decode($encrypted, true),
$result,
openssl_pkey_get_private($key),
OPENSSL_PKCS1_PADDING
);
if (!$success) {
throw new RuntimeException('decrypt failed');
}
echo $result . PHP_EOL;
Go
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/base64"
"encoding/pem"
"errors"
"fmt"
"os"
)
func main() {
prefix := "-----BEGIN PRIVATE KEY-----"
suffix := "-----END PRIVATE KEY-----"
encrypted := os.Args[1]
prikey := os.Args[2]
encryptedBytes, err := base64.StdEncoding.DecodeString(encrypted)
if err != nil {
fmt.Fprintln(os.Stderr, "invalid encrypted")
os.Exit(1)
}
key := prefix + "\n" + prikey + "\n" + suffix
result, err := rsaDecrypt(encryptedBytes, []byte(key))
if err != nil {
fmt.Fprintln(os.Stderr, "decrypt failed:", err)
os.Exit(1)
}
fmt.Println(string(result))
}
// rsaDecrypt use RSA PKCS#1 v1.5 Private‑key decryption。
func rsaDecrypt(encrypted, prikey []byte) ([]byte, error) {
block, _ := pem.Decode(prikey)
if block == nil {
return nil, errors.New("private key error")
}
parsedKey, err := x509.ParsePKCS8PrivateKey(block.Bytes)
if err != nil {
return nil, err
}
privateKey, ok := parsedKey.(*rsa.PrivateKey)
if !ok {
return nil, errors.New("invalid private key")
}
return rsa.DecryptPKCS1v15(rand.Reader, privateKey, encrypted)
}
2048-bit / PKCS1Padding
Java
import javax.crypto.Cipher;
import java.nio.charset.StandardCharsets;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Base64;
public class RSADecrypt {
public static void main(String[] args) throws Exception {
String encrypted = args[0];
String prikey = args[1];
String result = decrypt(encrypted, prikey);
System.out.println(result);
}
public static String decrypt(String cryptograph, String prikey) throws Exception {
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(
Base64.getDecoder().decode(prikey));
PrivateKey privateKey = KeyFactory.getInstance("RSA").generatePrivate(keySpec);
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.DECRYPT_MODE, privateKey);
byte[] b = Base64.getDecoder().decode(cryptograph);
return new String(cipher.doFinal(b), StandardCharsets.UTF_8);
}
}
Python
You need to install pycryptodome first:
pip install pycryptodome
#!/usr/bin/env python3
import base64
import sys
from Crypto.Cipher import PKCS1_v1_5
from Crypto.PublicKey import RSA
PREFIX = "-----BEGIN PRIVATE KEY-----"
SUFFIX = "-----END PRIVATE KEY-----"
encrypted = sys.argv[1]
prikey = sys.argv[2]
key = "{}\n{}\n{}".format(PREFIX, prikey, SUFFIX)
private_key = RSA.import_key(key)
cipher = PKCS1_v1_5.new(private_key)
sentinel = b""
result = cipher.decrypt(base64.b64decode(encrypted), sentinel)
if result == sentinel:
raise ValueError("decrypt failed")
print(result.decode("utf-8"))
PHP
<?php
$prefix = '-----BEGIN PRIVATE KEY-----';
$suffix = '-----END PRIVATE KEY-----';
$encrypted = $argv[1];
$prikey = $argv[2];
$key = $prefix . "\n" . $prikey . "\n" . $suffix;
$success = openssl_private_decrypt(
base64_decode($encrypted, true),
$result,
openssl_pkey_get_private($key),
OPENSSL_PKCS1_PADDING
);
if (!$success) {
throw new RuntimeException('decrypt failed');
}
echo $result . PHP_EOL;
Go
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/base64"
"encoding/pem"
"errors"
"fmt"
"os"
)
func main() {
prefix := "-----BEGIN PRIVATE KEY-----"
suffix := "-----END PRIVATE KEY-----"
encrypted := os.Args[1]
prikey := os.Args[2]
encryptedBytes, err := base64.StdEncoding.DecodeString(encrypted)
if err != nil {
fmt.Fprintln(os.Stderr, "invalid encrypted")
os.Exit(1)
}
key := prefix + "\n" + prikey + "\n" + suffix
result, err := rsaDecrypt(encryptedBytes, []byte(key))
if err != nil {
fmt.Fprintln(os.Stderr, "decrypt failed:", err)
os.Exit(1)
}
fmt.Println(string(result))
}
// rsaDecrypt use RSA PKCS#1 v1.5 Private‑key decryption。
func rsaDecrypt(encrypted, prikey []byte) ([]byte, error) {
block, _ := pem.Decode(prikey)
if block == nil {
return nil, errors.New("private key error")
}
parsedKey, err := x509.ParsePKCS8PrivateKey(block.Bytes)
if err != nil {
return nil, err
}
privateKey, ok := parsedKey.(*rsa.PrivateKey)
if !ok {
return nil, errors.New("invalid private key")
}
return rsa.DecryptPKCS1v15(rand.Reader, privateKey, encrypted)
}
2048-bit / OAEPWithSHA-256AndMGF1Padding
When 2048‑bit / OAEPWithSHA‑256AndMGF1Padding is selected in the console, decryption shall be performed with the matching 2048‑bit RSA private key. The OAEP digest and MGF1 digest both use SHA‑256, and the OAEP label is null.
Java
import javax.crypto.Cipher;
import javax.crypto.spec.OAEPParameterSpec;
import javax.crypto.spec.PSource;
import java.nio.charset.StandardCharsets;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.spec.MGF1ParameterSpec;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Base64;
public class RSADecrypt {
public static void main(String[] args) throws Exception {
String encrypted = args[0];
String prikey = args[1];
String result = decrypt(encrypted, prikey);
System.out.println(result);
}
public static String decrypt(String cryptograph, String prikey) throws Exception {
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(
Base64.getDecoder().decode(prikey));
PrivateKey privateKey = KeyFactory.getInstance("RSA").generatePrivate(keySpec);
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding");
OAEPParameterSpec parameterSpec = new OAEPParameterSpec(
"SHA-256",
"MGF1",
MGF1ParameterSpec.SHA256,
PSource.PSpecified.DEFAULT);
cipher.init(Cipher.DECRYPT_MODE, privateKey, parameterSpec);
byte[] b = Base64.getDecoder().decode(cryptograph);
return new String(cipher.doFinal(b), StandardCharsets.UTF_8);
}
}
Python
You need to install pycryptodome first:
pip install pycryptodome
#!/usr/bin/env python3
import base64
import sys
from Crypto.Cipher import PKCS1_OAEP
from Crypto.Hash import SHA256
from Crypto.PublicKey import RSA
from Crypto.Signature.pss import MGF1
PREFIX = "-----BEGIN PRIVATE KEY-----"
SUFFIX = "-----END PRIVATE KEY-----"
encrypted = sys.argv[1]
prikey = sys.argv[2]
key = "{}\n{}\n{}".format(PREFIX, prikey, SUFFIX)
private_key = RSA.import_key(key)
cipher = PKCS1_OAEP.new(
private_key,
hashAlgo=SHA256,
mgfunc=lambda seed, length: MGF1(seed, length, SHA256),
label=b"",
)
result = cipher.decrypt(base64.b64decode(encrypted)).decode("utf-8")
print(result)
PHP
PHP native openssl_private_decrypt cannot explicitly specify both the OAEP digest and MGF1‑digest at the same time. The following example uses phpseclib 3:
composer require phpseclib/phpseclib:^3.0
<?php
require __DIR__ . '/vendor/autoload.php';
use phpseclib3\Crypt\RSA;
$prefix = '-----BEGIN PRIVATE KEY-----';
$suffix = '-----END PRIVATE KEY-----';
$encrypted = $argv[1];
$prikey = $argv[2];
$key = $prefix . "\n" . $prikey . "\n" . $suffix;
$privateKey = RSA::loadPrivateKey($key)
->withPadding(RSA::ENCRYPTION_OAEP)
->withHash('sha256')
->withMGFHash('sha256')
->withLabel('');
$encryptedBytes = base64_decode($encrypted, true);
if ($encryptedBytes === false) {
throw new RuntimeException('invalid encrypted');
}
$result = $privateKey->decrypt($encryptedBytes);
echo $result . PHP_EOL;
Go
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"crypto/x509"
"encoding/base64"
"encoding/pem"
"errors"
"fmt"
"os"
)
func main() {
prefix := "-----BEGIN PRIVATE KEY-----"
suffix := "-----END PRIVATE KEY-----"
encrypted := os.Args[1]
prikey := os.Args[2]
encryptedBytes, err := base64.StdEncoding.DecodeString(encrypted)
if err != nil {
fmt.Fprintln(os.Stderr, "invalid encrypted")
os.Exit(1)
}
key := prefix + "\n" + prikey + "\n" + suffix
result, err := rsaDecrypt(encryptedBytes, []byte(key))
if err != nil {
fmt.Fprintln(os.Stderr, "decrypt failed:", err)
os.Exit(1)
}
fmt.Println(string(result))
}
// rsaDecrypt use RSA OAEP-SHA256 private‑key decryption.
func rsaDecrypt(encrypted, prikey []byte) ([]byte, error) {
block, _ := pem.Decode(prikey)
if block == nil {
return nil, errors.New("private key error")
}
parsedKey, err := x509.ParsePKCS8PrivateKey(block.Bytes)
if err != nil {
return nil, err
}
privateKey, ok := parsedKey.(*rsa.PrivateKey)
if !ok {
return nil, errors.New("invalid private key")
}
// label send nil represents an empty byte‑string;MGF1 and OAEP all use SHA-256。
return rsa.DecryptOAEP(sha256.New(), rand.Reader, privateKey, encrypted, nil)
}