Я развернул свое приложение для Android для внутреннего тестирования, а также включил его в консоли Google Play, как показано на снимке экрана ниже. p>

Здесь это пример кода для моего Android приложение
Код: Выделить всё
val integrityTokenResponse = integrityTokenProvider.request(
StandardIntegrityTokenRequest.builder()
.setRequestHash(hash)
.build()
)
integrityTokenResponse.addOnSuccessListener { response ->
lifecycleScope.launch {
val apiResponse = retrofit.verifyHash(VerifyHashRequest(response.token()))
runOnUiThread {
textView.text = apiResponse.message
}
}
}.addOnFailureListener { exception ->
Toast.makeText(this@MainActivity,"Failure ${exception.message}",Toast.LENGTH_LONG).show()
}
Код: Выделить всё
import { GoogleAuth } from "google-auth-library";
import path from "path";
const {
token,
}: {
token: string;
} = await request.json();
const keyFilePath = path.resolve(
"./my.json"
);
const auth = new GoogleAuth({
keyFile: keyFilePath,
scopes: ["https://www.googleapis.com/auth/playintegrity"],
});
const packageName = "myandroidpackagename";
const client = await auth.getClient();
const accessToken = await client.getAccessToken();
const url = `https://playintegrity.googleapis.com/v1/${packageName}:decodeIntegrityToken`;
console.log("token", token);
console.log("accessToken", accessToken.token);
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${accessToken.token}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
integrityToken: token,
}),
});
console.log("response", response);
if (!response.ok) {
throw new Error(response.statusText);
}
const json = await response.json();
return Response.json({
message: JSON.stringify(json),
});
} catch (e) {
return Response.json({
message: "Error " + e,
});
}
В консоли Google Play я связал свой облачный проект Google< /p>
и в моем облачном проекте Google я включил Google Play Integrity API
[img]https:/ /i.sstatic.net/bmmhr7LU.png[/img]
В моем проекте Google Cloud я включил учетные записи служб и загрузил файл json, который я называю my.json в приведенном выше node.js код
Я вижу, что токен и accessToken печатаются, но в ответ выдается ошибка:
Код: Выделить всё
{
status: 403,
statusText: 'Forbidden',
headers: Headers {
vary: 'Origin, X-Origin, Referer',
'content-type': 'application/json; charset=UTF-8',
date: 'Sun, 29 Dec 2024 08:19:31 GMT',
server: 'ESF',
'content-length': '154',
'x-xss-protection': '0',
'x-frame-options': 'SAMEORIGIN',
'x-content-type-options': 'nosniff',
'alt-svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000'
},
body: ReadableStream { locked: false, state: 'readable', supportsBYOB: true },
bodyUsed: false,
ok: false,
redirected: false,
type: 'basic',
url: 'https://playintegrity.googleapis.com/v1/myapppackage:decodeIntegrityToken'
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... dden-error