一、java根据APIKEY获取一个用户的token
public static void main(String[] args) throws IOException {
HashMap<String, String> params = new HashMap<>();
params.put( “userId”, “userid” );
params.put( “key”, “APIKEY” );
FormBody.Builder builder = new FormBody.Builder();
for ( Map.Entry<String, String> entry : params.entrySet() ) {
builder.add( entry.getKey(), entry.getValue() );
}
RequestBody formBody = builder.build();
Request request = new Request.Builder()
.url( “https://test-api.sumsub.com/resources/accessTokens?userId=userid&key=APIKEY” )
.post( formBody )
.build();
OkHttpClient client = new OkHttpClient();
Response response = client.newCall(request).execute();
String result = response.body().string();
System.out.println(result);
System.out.println(result);
}
二、根据token生成一个用户的kyc页面
<style>
#idensic {width: 100%;border: 0;padding: 0;margin: 0;}
body {margin: 0;padding: 0;}
</style>
<div id=”idensic”></div>
<script src=”https://test-api.sumsub.com/idensic/static/idensic.js”></script>
<script>
var queryParams = getQueryParams();
var id = idensic.init(
‘#idensic’,
{
accessToken: queryParams.accessToken || ‘791045b7-1fe3-4f93-a4e7-d6ac17ff995b’,
userId: queryParams.userId || ‘userid’,
applicantId: queryParams.applicantId || null,
firstName: queryParams.firstName || ‘firstName’,
lastName: queryParams.lastName || ‘lastName’,
requiredDocuments: queryParams.requiredDocuments || ‘IDENTITY:PASSPORT,DRIVERS;SELFIE:SELFIE’
},
function (messageType, payload) {
// idCheck.onReady, idCheck.onResize, idCheck.onCancel, idCheck.onSuccess, idCheck.onApplicantCreated
console.log(‘[IDENSIC DEMO] Idensic message:’, messageType, payload);
}
);
function getQueryParams() {
var params = {};
let queryPart = document.location.href.split(‘?’)[1];
if (queryPart) {
var query = queryPart.split(‘&’);
for (var i in query) {
var param = query[i].split(‘=’);
params[param[0]] = param[1];
}
}
return params;
}
</script>
三、在线测试post通讯(repl.it/repls/RealBlaringAdministrators)
写一个index.js,js版本的获取token内容如下
var unirest = require(“unirest”);
var req = unirest(“POST”, “https://test-api.sumsub.com/resources/accessTokens”);
req.query({
“userId”: “USERID”,
“key”: “APIKEY”
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
转载于:https://my.oschina.net/duojin/blog/1929777
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/101481.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...