简体   繁体   English

如何在后端验证请求

[英]How to verify requests in backend

I'm creating a payment android library( aar ) and i have to make sure that all of the requests that i got in back-end are from my lib not a fake lib. 我正在创建一个付款android库( aar ),我必须确保我在back-end收到的所有请求都来自我的库,而不是假库。

how can i do it? 我该怎么做?

I used two ways before: 我之前使用过两种方法:

1- Easy and bad way: Try to use a hardcoded String like JWT in your app and use a strong obfuscator to avoid decompiling the application. 1-简单又糟糕的方法:尝试在应用程序中使用像JWT这样的硬编码字符串,并使用强大的混淆器来避免对应用程序进行反编译。

2- Better way: You can use instance id and send it to your backend and server can inquire this id from the Google and there are some elements like package id in the response which server can use to accept or reject the request. 2-更好的方法:您可以使用instance id并将其发送到后端,服务器可以从Google查询此ID,并且响应中包含一些元素(如package id ,服务器可以使用这些元素接受或拒绝请求。

A sample response from the Google: 来自Google的样本回复:

{
  "application":"com.iid.example",
  "authorizedEntity":"123456782354",
  "platform":"Android",
  "attestStatus":"ROOTED",
  "appSigner":"1a2bc3d4e5",
  "connectionType":"WIFI",
  "connectDate":"2015-05-12
  }
}

reference: https://developers.google.com/instance-id/reference/server 参考: https : //developers.google.com/instance-id/reference/server

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何验证App Engine后端上的Android ID令牌 - How to verify Android id token on App Engine backend 如何使用Google API在服务器端验证Android请求 - How to verify android requests in server side using Google apis 在Android应用上获取id令牌并在后端服务器上验证它(如何使用id令牌?) - Get id token on Android app and verify it on backend server (How to use id token?) 在 PHP 后端 API 中验证 Cognito 身份 - Verify Cognito identity in PHP backend API 验证Android后端调用Python中的Id令牌 - Verify Id Token In Android Backend Call to Python 如何使用用户凭据为移动应用程序和后端服务器通信签名HTTP请求? - How to sign HTTP requests with user credentials for mobile app and backend server communication? 如何从Android应用向App Engine后端发出请求? - How do I make requests from an Android app to an App Engine backend? 适用于Android客户端的后端服务器-是否可以验证客户已购买了该应用程序? - Backend server for Android clients - Possible to verify that the customer has bought the application? 使用Firebase身份验证对Android进行身份验证,并发送令牌以验证后端Django - Authenticating Android with firebase Authentication and send token to verify to backend Django 如何验证电话是否已对接? - How to verify if the phone is docked?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM