এই পৃষ্ঠায় বর্ণনা করা হয়েছে কিভাবে থার্ড-পার্টি SDK-গুলো ইনলাইন ইনস্টলকে ইন্টিগ্রেট করতে পারে। ইনলাইন ইনস্টল হলো গুগল প্লে-এর একটি নতুন পরীক্ষামূলক ফিচার, যা একটি হাফ-শিট ইন্টারফেসে গুগল প্লে অ্যাপের প্রোডাক্টের বিবরণ প্রদর্শন করে। ইনলাইন ইনস্টল ব্যবহারকারীদের অ্যাপের কনটেক্সট থেকে বের না হয়েই একটি নির্বিঘ্ন অ্যাপ ইনস্টল প্রক্রিয়ার অভিজ্ঞতা দেয়।
তৃতীয় পক্ষের SDK ডেভেলপাররা তাদের SDK-তে ইনলাইন ইনস্টল ফিচারটি অন্তর্ভুক্ত করতে পারেন, যাতে সেই SDK ব্যবহারকারী অ্যাপ ডেভেলপাররা তাদের অ্যাপের জন্য ইনলাইন ইনস্টল অ্যাক্সেস করতে পারেন।
প্রয়োজনীয়তা
অ্যাপে ইনলাইন ইনস্টল হাফ শীট ইন্টারফেসটি প্রদর্শিত হওয়ার জন্য:
- গুগল প্লে-এর সর্বনিম্ন সংস্করণ অবশ্যই ৪০.৪ হতে হবে।
- অ্যান্ড্রয়েড এপিআই লেভেল অবশ্যই ২৩ বা তার বেশি হতে হবে।
প্রক্রিয়া স্থাপত্য
ইনলাইন ইনস্টল প্রক্রিয়ার স্থাপত্যটি নিম্নলিখিত চিত্রে দেখানো হয়েছে:

- গুগল প্লে সার্ভারগুলো অথেনটিকেটেড এনক্রিপশন উইথ অ্যাসোসিয়েটেড ডেটা (AEAD) এনক্রিপশন কী তৈরি করে এবং সেই কী-গুলো একটি গুগল ক্লাউড প্ল্যাটফর্ম (GCP) সিক্রেট ম্যানেজার ইনস্ট্যান্সে অন্তর্ভুক্ত করে।
- তৃতীয় পক্ষের ইন্টিগ্রেটর GCP Secret Manager থেকে AEAD কী-টি সংগ্রহ করে।
- তৃতীয় পক্ষের ইন্টিগ্রেটর ইনলাইন ইনস্টল
Intentডেটা এনক্রিপ্ট করে, ইনলাইন ইনস্টল ইন্টেন্টটি চালু করতে ব্যবহৃত ডিপ লিঙ্কে পাঠানো সাইফারটেক্সট তৈরি করে এবং রেসপন্স হিসেবে ক্লায়েন্টের কাছে ডিপ লিঙ্কগুলো পাঠায়। - যখন ডিপ লিঙ্কটি অনুসরণ করা হয়, তখন গুগল প্লে অ্যাপ অভিপ্রায়টি পরিচালনা করে।
ইনলাইন ইনস্টল প্রক্রিয়া ব্যবহার করার জন্য কোনো থার্ড-পার্টি SDK কনফিগার করতে, নিম্নলিখিত ধাপগুলো সম্পন্ন করুন।
গুগল ক্লাউড প্রজেক্টে পরিষেবা অ্যাকাউন্ট তৈরি করুন
এই ধাপে, আপনি গুগল ক্লাউড কনসোল ব্যবহার করে একটি সার্ভিস অ্যাকাউন্ট সেট আপ করবেন।
- একটি গুগল ক্লাউড প্রজেক্ট সেট আপ করুন:
- একটি গুগল ক্লাউড অর্গানাইজেশন তৈরি করুন। যখন আপনি একটি গুগল ওয়ার্কস্পেস বা ক্লাউড আইডেন্টিটি অ্যাকাউন্ট তৈরি করেন এবং এটিকে আপনার ডোমেইন নামের সাথে যুক্ত করেন, তখন অর্গানাইজেশন রিসোর্সটি স্বয়ংক্রিয়ভাবে তৈরি হয়ে যায়। বিস্তারিত জানতে, ‘অর্গানাইজেশন রিসোর্স তৈরি এবং পরিচালনা’ দেখুন।
- পূর্ববর্তী ধাপে তৈরি করা Google Cloud অ্যাকাউন্ট ব্যবহার করে GCP কনসোলে লগ ইন করুন, তারপর একটি Google Cloud প্রজেক্ট তৈরি করুন। বিস্তারিত জানতে, "একটি Google Cloud প্রজেক্ট তৈরি করুন" দেখুন।
- তৈরি করা গুগল ক্লাউড প্রজেক্টে একটি সার্ভিস অ্যাকাউন্ট তৈরি করুন। এই সার্ভিস অ্যাকাউন্টটি আপনার সার্ভারগুলোর পক্ষ থেকে সিমেট্রিক কী অ্যাক্সেস করার জন্য গুগল ক্লাউড আইডেন্টিটি হিসেবে ব্যবহৃত হয়। বিস্তারিত জানতে, “একটি সার্ভিস অ্যাকাউন্ট তৈরি করুন” অংশটি দেখুন।
- আগ্রহ ফর্মে ইনপুট করা একই Google Workspace Customer ID (GWCID) / Dasher ID ব্যবহার করুন।
- ওই সার্ভিস অ্যাকাউন্টের প্রাইভেট কী তৈরি ও ডাউনলোড করুন।
- সেই সার্ভিস অ্যাকাউন্টের জন্য একটি কী তৈরি করুন। বিস্তারিত জানতে, ‘একটি সার্ভিস অ্যাকাউন্ট কী তৈরি করুন’ দেখুন।
- সার্ভিস অ্যাকাউন্ট কী-টি ডাউনলোড করুন এবং আপনার সার্ভারে এটিকে সহজে খুঁজে পাওয়ার মতো জায়গায় রাখুন, কারণ সিমেট্রিক কী-গুলির জন্য গুগল ক্লাউড রিসোর্স অ্যাক্সেস করার প্রমাণীকরণের কাজে এটি ব্যবহৃত হয়। বিস্তারিত জানতে, “Get a service account key” দেখুন।
পরিচয়পত্র পুনরুদ্ধার করুন
এই ধাপে, আপনি সিক্রেট ম্যানেজার থেকে সিমেট্রিক কী-টি সংগ্রহ করে আপনার নিজের সার্ভার স্টোরেজে নিরাপদে সংরক্ষণ করেন (উদাহরণস্বরূপ, একটি JSON ফাইলে)। এই কী-টি ইনলাইন ইনস্টল ডেটা সাইফারটেক্সট তৈরি করতে ব্যবহৃত হয়।
secret_id/secretId ভ্যালুগুলো সিক্রেট ম্যানেজারের ভেতরের সিক্রেটের নামকে নির্দেশ করে; প্লে-প্রদত্ত sdk_id ভ্যালুটির আগে hsdp-3p-key- যোগ করে এই নামটি তৈরি করা হয়। উদাহরণস্বরূপ, যদি sdk_id হয় abc , তাহলে সিক্রেটের নাম হবে hsdp-3p-key-abc ।
গোপন সংস্করণগুলো প্রতি মঙ্গলবার দুপুর ২টায় (UTC) সাপ্তাহিক ভিত্তিতে আপডেট করা হয়। দ্বিতীয়-নতুনতম কীগুলো পরবর্তী রোটেশন পর্যন্ত কাজ করতে থাকে, এবং কী ম্যাটেরিয়ালগুলো সাপ্তাহিক ভিত্তিতে নতুন করে সংগ্রহ ও সংরক্ষণ করা উচিত।
পাইথন উদাহরণ
নিম্নলিখিত কোড উদাহরণটি একটি JSON ফাইলে সংরক্ষিত অ্যাক্সেস টোকেন ব্যবহার করে GCP Secret Manager-এর কী মেটেরিয়াল অ্যাক্সেস করে এবং তা কনসোলে প্রিন্ট করে।
#!/usr/bin/env python3
# Import the Secret Manager client library.
from google.cloud import secretmanager
from google.oauth2 import service_account
import google_crc32c
# Create a service account key file.
service_account_key_file = "<json key file of the service account>"
credentials = service_account.Credentials.from_service_account_file(service_account_key_file)
# Create the Secret Manager client.
client = secretmanager.SecretManagerServiceClient(
credentials=credentials
)
# Build the resource name of the secret version.
name = f"projects/prod-play-hsdp-3p-caller-auth/secrets/<secret_id>/versions/latest"
# Access the secret version.
response = client.access_secret_version(request={"name": name})
# Verify payload checksum.
crc32c = google_crc32c.Checksum()
crc32c.update(response.payload.data)
if response.payload.data_crc32c != int(crc32c.hexdigest(), 16):
print("Data corruption detected.")
# A keyset created with "tinkey create-keyset --key-template=AES256_GCM". Note
# that this keyset has the secret key information in cleartext.
keyset = response.payload.data.decode("UTF-8")
# WARNING: Do not print the secret in a production environment. Please store it
# in a secure storage.
with open('<key file name>', 'w') as f:
f.write(keyset)
জাভা উদাহরণ
নিম্নলিখিত কোড উদাহরণটি একটি JSON ফাইলে সংরক্ষিত অ্যাক্সেস টোকেন ব্যবহার করে GCP Secret Manager-এর মূল উপাদান অ্যাক্সেস করে এবং তা একটি JSON ফাইলে লেখে।
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.api.gax.core.CredentialsProvider;
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.ServiceAccountCredentials;
import com.google.cloud.secretmanager.v1.AccessSecretVersionResponse;
import com.google.cloud.secretmanager.v1.SecretManagerServiceClient;
import com.google.cloud.secretmanager.v1.SecretManagerServiceSettings;
import com.google.cloud.secretmanager.v1.SecretVersionName;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.zip.CRC32C;
import java.util.zip.Checksum;
/** */
final class ThirdPartySecretAccessGuide {
private ThirdPartySecretAccessGuide() {}
public static void main(String[] args) throws IOException {
accessSecretVersion();
}
public static void accessSecretVersion() throws IOException {
// TODO(developer): Replace these variables before running the sample.
String projectId = "projectId";
String secretId = "secretId";
String versionId = "versionId";
String accessTokenPrivateKeyPath = "path/to/credentials.json";
String secretMaterialOutputPath = "path/to/secret.json";
accessSecretVersion(
projectId, secretId, versionId, accessTokenPrivateKeyPath, secretMaterialOutputPath);
}
// Access the payload for the given secret version if one exists. The version
// can be a version number as a string (e.g. "5") or an alias (e.g. "latest").
public static void accessSecretVersion(
String projectId,
String secretId,
String versionId,
String accessTokenPrivateKeyPath,
String secretMaterialOutputPath)
throws IOException {
// We can explicitly instantiate the SecretManagerServiceClient (below) from a json file if we:
// 1. Create a CredentialsProvider from a FileInputStream of the JSON file,
CredentialsProvider credentialsProvider =
FixedCredentialsProvider.create(
ServiceAccountCredentials.fromStream(new FileInputStream(accessTokenPrivateKeyPath)));
// 2. Build a SecretManagerService Settings object from that credentials provider, and
SecretManagerServiceSettings secretManagerServiceSettings =
SecretManagerServiceSettings.newBuilder()
.setCredentialsProvider(credentialsProvider)
.build();
// 3. Initialize client that will be used to send requests by passing the settings object to
// create(). This client only needs to be created once, and can be reused for multiple requests.
// After completing all of your requests, call the "close" method on the client to safely clean
// up any remaining background resources.
try (SecretManagerServiceClient client =
SecretManagerServiceClient.create(secretManagerServiceSettings)) {
SecretVersionName secretVersionName = SecretVersionName.of(projectId, secretId, versionId);
// Access the secret version.
AccessSecretVersionResponse response = client.accessSecretVersion(secretVersionName);
// Verify checksum. The used library is available in Java 9+.
// If using Java 8, you may use the following:
// https://github.com/google/guava/blob/e62d6a0456420d295089a9c319b7593a3eae4a83/guava/src/com/google/common/hash/Hashing.java#L395
byte[] data = response.getPayload().getData().toByteArray();
Checksum checksum = new CRC32C();
checksum.update(data, 0, data.length);
if (response.getPayload().getDataCrc32C() != checksum.getValue()) {
System.out.printf("Data corruption detected.");
return;
}
String payload = response.getPayload().getData().toStringUtf8();
// Print the secret payload.
//
// WARNING: Do not print the secret in a production environment - this
// snippet is showing how to access the secret material.
System.out.printf("Plaintext: %s\n", payload);
// Write the JSON secret material payload to a json file
try (PrintWriter out =
new PrintWriter(Files.newBufferedWriter(Paths.get(secretMaterialOutputPath), UTF_8))) {
out.write(payload);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
অ্যাপ্লিকেশনের ডিফল্ট ক্রেডেনশিয়াল সেট করুন
আপনি যদি জাভা ইমপ্লিমেন্টেশনে JSON ফাইলে প্রাইভেট কী পাস করার জন্য CredentialsProvider ব্যবহার করতে না চান, তাহলে আপনি Application Default Credentials (ADC) সেট করে ইমপ্লিমেন্টেশনটি পরিবর্তন করতে পারেন:
- ক্লায়েন্ট লাইব্রেরিগুলোকে বলে দিন সার্ভিস অ্যাকাউন্ট কী-টি কোথায় খুঁজে পাওয়া যাবে।
- জাভা প্রজেক্টে মেভেন ডিপেন্ডেন্সি যোগ করুন ।
-
SecretManagerServiceClient.create()কল করুন , যা (ধাপ ১-এর কারণে) স্বয়ংক্রিয়ভাবে প্রমাণীকরণ সম্পন্ন করে।
এই ধাপগুলো জাভা ইমপ্লিমেন্টেশনকে নিম্নোক্তভাবে পরিবর্তন করে:
-
CredentialsProviderএবংSecretManagerServiceSettingsঅবজেক্ট তৈরি করার প্রয়োজনীয়তা দূর করা হয়েছে। -
SecretManagerServiceClient.create()কলটিতে কোনো আর্গুমেন্ট অন্তর্ভুক্ত না করার জন্য পরিবর্তন আনা হচ্ছে।
সাইফারটেক্সট তৈরি করুন এবং ডিপ লিঙ্ক জেনারেট করুন
এই ধাপে, আপনি Tink ক্রিপ্টোগ্রাফি লাইব্রেরি ব্যবহার করে InlineInstallData প্রোটোবাফ অবজেক্ট থেকে enifd ( InlineInstallData সাইফারটেক্সট) তৈরি করবেন। InlineInstallData প্রোটোটি নিম্নরূপে সংজ্ঞায়িত করা হয়েছে:
syntax = "proto2";
package hsdpexperiments;
option java_package = "com.google.hsdpexperiments";
option java_multiple_files = true;
// InlineInstallData is used by 3p auth callers to generate "encrypted inline
// flow data" (enifd) which is decrypted in PGS to verify authenticity and
// freshness.
message InlineInstallData {
// The timestamp which indicates the time encrypted data is generated.
// Used to validate freshness (i.e. generation time in past 4 hours).
// Required.
optional int64 timestamp_ms = 1;
// The docid of the app that we want to open inline install page for.
// This is the package name.
// Required.
optional string target_package_name = 2;
// This is the name of the app requesting the ad from Google Ad Serving
// system.
// Required.
optional string caller_package_name = 3;
// This is the advertising id that will be collected by 3P Ad SDKs.
// Optional.
optional string advertising_id = 4;
// This is used to indicate the network from where the inline install was
// requested.
// Required.
optional string ad_network_id = 5;
}
এই ধাপে আপনি এই প্যারামিটারগুলো ব্যবহার করে ডিপ লিঙ্ক ইউআরএলটিও তৈরি করবেন:
| ক্ষেত্র | বর্ণনা | প্রয়োজনীয় |
|---|---|---|
| আইডি | যে অ্যাপটি ইনস্টল করা হবে তার প্যাকেজ নাম । | হ্যাঁ |
| ইনলাইন | ইনলাইন হাফ শীট ইনস্টল করার অনুরোধ করা হলে এটি ' true সেট করুন; false হলে, ইন্টেন্টটি গুগল প্লে-তে ডিপ লিঙ্ক করবে। | হ্যাঁ |
| enifd | 3P SDK-গুলোর এনক্রিপ্টেড শনাক্তকারী। | হ্যাঁ |
| বাম | একটি অভ্যন্তরীণ শনাক্তকারী। | হ্যাঁ |
| 3pAuthCallerId | এসডিকে শনাক্তকারী। | হ্যাঁ |
| তালিকা | কাস্টম স্টোর তালিকার জন্য লক্ষ্যবস্তু নির্দিষ্ট করার একটি ঐচ্ছিক প্যারামিটার। | না |
| রেফারার | একটি ঐচ্ছিক রেফারার ট্র্যাকিং স্ট্রিং। | না |
পাইথন উদাহরণ
নিম্নলিখিত কমান্ডটি InlineInstallData.proto থেকে পাইথন কোড তৈরি করে:
protoc InlineInstallData.proto --python_out=.
নিম্নলিখিত পাইথন নমুনা কোডটি InlineInstallData তৈরি করে এবং সাইফারটেক্সট তৈরির জন্য এটিকে সিমেট্রিক কী দিয়ে এনক্রিপ্ট করে:
#!/usr/bin/env python3
# Import the Secret Manager client library.
import base64
import time
import inline_install_data_pb2 as InlineInstallData
import tink
from tink import aead
from tink import cleartext_keyset_handle
# Read the stored symmetric key.
with open("example3psecret.json", "r") as f:
keyset = f.read()
"""Encrypt and decrypt using AEAD."""
# Register the AEAD key managers. This is needed to create an Aead primitive later.
aead.register()
# Create a keyset handle from the cleartext keyset in the previous
# step. The keyset handle provides abstract access to the underlying keyset to
# limit access of the raw key material. WARNING: In practice, it is unlikely
# you will want to use a cleartext_keyset_handle, as it implies that your key
# material is passed in cleartext, which is a security risk.
keyset_handle = cleartext_keyset_handle.read(tink.JsonKeysetReader(keyset))
# Retrieve the Aead primitive we want to use from the keyset handle.
primitive = keyset_handle.primitive(aead.Aead)
inlineInstallData = InlineInstallData.InlineInstallData()
inlineInstallData.timestamp_ms = int(time.time() * 1000)
inlineInstallData.target_package_name = "x.y.z"
inlineInstallData.caller_package_name = "a.b.c"
inlineInstallData.ad_network_id = "<sdk_id>"
# Use the primitive to encrypt a message. In this case the primary key of the
# keyset will be used (which is also the only key in this example).
ciphertext = primitive.encrypt(inlineInstallData.SerializeToString(), b'<sdk_id>')
print(f"InlineInstallData Ciphertext: {ciphertext}")
# Base64 Encoded InlineInstallData Ciphertext
enifd = base64.urlsafe_b64encode(ciphertext).decode('utf-8')
print(enifd)
# Deeplink
print(f"https://play.google.com/d?id={inlineInstallData.target_package_name}\&inline=true\&enifd={enifd}\&lft=1\&3pAuthCallerId={inlineInstallData.ad_network_id}")
নিম্নলিখিত কমান্ডটি চালিয়ে পাইথন স্ক্রিপ্টটি কার্যকর করুন:
python <file_name>.py
জাভা উদাহরণ
নিম্নলিখিত কমান্ডটি InlineInstallData.proto থেকে জাভা কোড তৈরি করে:
protoc InlineInstallData.proto --java_out=.
নিম্নলিখিত জাভা নমুনা কোডটি InlineInstallData তৈরি করে এবং সাইফারটেক্সট তৈরির জন্য এটিকে সিমেট্রিক কী দিয়ে এনক্রিপ্ট করে:
package com.google.hsdpexperiments;
import static com.google.common.io.BaseEncoding.base64Url;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.flags.Flag;
import com.google.common.flags.FlagSpec;
import com.google.common.flags.Flags;
import com.google.crypto.tink.Aead;
import com.google.crypto.tink.InsecureSecretKeyAccess;
import com.google.crypto.tink.KeysetHandle;
import com.google.crypto.tink.TinkJsonProtoKeysetFormat;
import com.google.crypto.tink.aead.AeadConfig;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.Security;
import java.time.Duration;
import org.conscrypt.Conscrypt;
/** info on encryption in https://github.com/google/tink#learn-more */
final class ThirdPartyEnifdGuide {
@FlagSpec(
name = "third_party_id",
help = "the identifier associated with the 3p for which to generate the enifd")
private static final Flag<String> thirdPartyAuthCallerId = Flag.value("");
@FlagSpec(name = "package_name", help = "the package name of the target app")
private static final Flag<String> packageName = Flag.value("");
@FlagSpec(name = "caller_package_name", help = "the package name of the caller app")
private static final Flag<String> callerPackageName = Flag.value("");
@FlagSpec(name = "secret_filename", help = "the path to the json file with the secret material")
private static final Flag<String> secretFilename = Flag.value("");
private ThirdPartyEnifdGuide() {}
public static void main(String[] args) throws Exception {
// parse flags
Flags.parse(args);
// File keyFile = new File(args[0]);
Path keyFile = Paths.get(secretFilename.get());
// Create structured inline flow data
InlineInstallData idrp =
InlineInstallData.newBuilder()
.setTargetPackageName(packageName.get())
.setCallerPackageName(callerPackageName.get())
.setTimestampMs(System.currentTimeMillis())
.setAdNetworkId(thirdPartyAuthCallerId.get())
.build();
// we can print this out here to make sure it's well formatted, this will help debug
System.out.println(idrp.toString());
// Register all AEAD key types with the Tink runtime.
Conscrypt.checkAvailability();
Security.addProvider(Conscrypt.newProvider());
AeadConfig.register();
// Read AEAD key downloaded from secretmanager into keysethandle
KeysetHandle handle =
TinkJsonProtoKeysetFormat.parseKeyset(
new String(Files.readAllBytes(keyFile), UTF_8), InsecureSecretKeyAccess.get());
// Generate enifd using tink library
Aead aead = handle.getPrimitive(Aead.class);
byte[] plaintext = idrp.toByteArray();
byte[] ciphertext = aead.encrypt(plaintext, thirdPartyAuthCallerId.get().getBytes(UTF_8));
String enifd = base64Url().omitPadding().encode(ciphertext);
// Build deeplink, escaping ampersands (TODO: verify this is necessary while testing e2e)
String deeplink =
"https://play.google.com/d?id="
+ packageName.get()
+ "\\&inline=true\\&enifd="
+ enifd
+ "\\&lft=1\\&3pAuthCallerId="
+ thirdPartyAuthCallerId.get();
System.out.println(deeplink);
}
}
অবশেষে, জাভা প্রোগ্রামটিকে একটি বাইনারিতে বিল্ড করুন এবং নিম্নলিখিত কোড ব্যবহার করে এটিকে কল করুন:
path/to/binary/ThirdPartyEnifdGuide --secret_filename=path/to/jsonfile/example3psecret.json --package_name=<package_name_of_target_app> --third_party_id=<3p_caller_auth_id>
-
secret_filenameফ্ল্যাগটি গোপনীয় উপাদান ধারণকারী JSON ফাইলের পাথ নির্দিষ্ট করে। -
package_nameফ্ল্যাগটি হলো টার্গেট অ্যাপের ডক আইডি। -
third_party_idফ্ল্যাগটি তৃতীয় পক্ষের কলারের অথেন্টিকেশন আইডি (অর্থাৎ,<sdk_id>) নির্দিষ্ট করতে ব্যবহৃত হয়।
ইনলাইন ইনস্টল ইন্টেন্ট চালু করুন
পূর্ববর্তী ধাপে তৈরি হওয়া ডিপ লিঙ্কটি পরীক্ষা করার জন্য, ADB ইনস্টল করা আছে এমন একটি ওয়ার্কস্টেশনের সাথে একটি অ্যান্ড্রয়েড ডিভাইস (ইউএসবি ডিবাগিং চালু আছে কিনা তা নিশ্চিত করুন) সংযুক্ত করুন এবং নিম্নলিখিত কমান্ডটি চালান:
adb shell am start "<output_from_the_previous_python_or_java_code>"
ক্লায়েন্ট কোডে, নিম্নলিখিত পদ্ধতিগুলোর (কোটলিন বা জাভা) যেকোনো একটি ব্যবহার করে ইন্টেন্টটি পাঠান।
কোটলিন
val intent = Intent(Intent.ACTION_VIEW)
val deepLinkUrl = "<output_from_the_previous_python_or_java_code>"
intent.setPackage("com.android.vending")
intent.data = Uri.parse(deepLinkUrl)
val packageManager = context.getPackageManager()
if (intent.resolveActivity(packageManager) != null) {
startActivityForResult(intent, 0)
} else {
// Fallback to deep linking to full Play Store.
}
জাভা
Intent intent = new Intent(Intent.ACTION_VIEW);
String id = "exampleAppToBeInstalledId";
String deepLinkUrl = "<output_from_the_previous_python_or_java_code>";
intent.setPackage("com.android.vending");
intent.setData(Uri.parse(deepLinkUrl));
PackageManager packageManager = context.getPackageManager();
if (intent.resolveActivity(packageManager) != null) {
startActivityForResult(intent, 0);
} else {
// Fallback to deep linking to full Play Store.
}
পরিশিষ্ট
নিম্নলিখিত বিভাগগুলিতে নির্দিষ্ট কিছু ব্যবহারের ক্ষেত্রে অতিরিক্ত নির্দেশনা প্রদান করা হয়েছে।
পাইথন পরিবেশ প্রস্তুত করুন
পাইথন স্যাম্পল কোডটি চালানোর জন্য, আপনার ওয়ার্কস্টেশনে পাইথন এনভায়রনমেন্ট সেট আপ করুন এবং প্রয়োজনীয় ডিপেন্ডেন্সিগুলো ইনস্টল করুন।
পাইথন পরিবেশ সেট আপ করুন:
পাইথন ৩.১১ ইনস্টল করুন (যদি আগে থেকেই ইনস্টল করা থাকে, তবে এই ধাপটি বাদ দিন):
sudo apt install python3.11pip ইনস্টল করুন:
sudo apt-get install pipvirtualenvইনস্টল করুন :sudo apt install python3-virtualenvএকটি ভার্চুয়াল পরিবেশ তৈরি করুন (Tink নির্ভরতার জন্য আবশ্যক):
virtualenv inlineinstall --python=/usr/bin/python3.11
ভার্চুয়াল পরিবেশে প্রবেশ করুন:
source inlineinstall/bin/activateপিপ আপডেট করুন:
python -m pip install --upgrade pipপ্রয়োজনীয় নির্ভরতা ইনস্টল করুন:
টিঙ্ক ইনস্টল করুন:
pip install tinkGoogle crc32c ইনস্টল করুন:
pip install google-crc32cসিক্রেট ম্যানেজার ইনস্টল করুন:
pip install google-cloud-secret-managerপ্রোটোবাফ কম্পাইলার ইনস্টল করুন:
sudo apt install protobuf-compiler
C++ enifd প্রজন্ম
নিম্নলিখিতটি একটি C++ উদাহরণ যা আমরা enifd তৈরি করার জন্য লিখেছি এবং অভ্যন্তরীণভাবে যাচাই করেছি।
নিম্নলিখিতভাবে C++ কোড ব্যবহার করে enifd তৈরি করা যেতে পারে:
// A command-line example for using Tink AEAD w/ key template aes128gcmsiv to
// encrypt an InlineInstallData proto.
#include <chrono>
#include <iostream>
#include <memory>
#include <string>
#include "<path_to_protoc_output>/inline_install_data.proto.h"
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/strings/escaping.h"
#include "absl/strings/string_view.h"
#include "tink/cc/aead.h"
#include "tink/cc/aead_config.h"
#include "tink/cc/aead_key_templates.h"
#include "tink/cc/config/global_registry.h"
#include "tink/cc/examples/util/util.h"
#include "tink/cc/keyset_handle.h"
#include "tink/cc/util/status.h"
#include "tink/cc/util/statusor.h"
ABSL_FLAG(std::string, keyset_filename, "",
"Keyset file (downloaded from secretmanager) in JSON format");
ABSL_FLAG(std::string, associated_data, "",
"Associated data for AEAD (default: empty");
namespace {
using ::crypto::tink::Aead;
using ::crypto::tink::AeadConfig;
using ::crypto::tink::KeysetHandle;
using ::crypto::tink::util::Status;
using ::crypto::tink::util::StatusOr;
} // namespace
namespace tink_cc_examples {
// AEAD example CLI implementation.
void AeadCli(const std::string& keyset_filename,
absl::string_view associated_data) {
Status result = AeadConfig::Register();
if (!result.ok()) {
std::clog << "Failed to register AeadConfig";
return;
}
// Read the keyset from file.
StatusOr<std::unique_ptr<KeysetHandle>> keyset_handle =
ReadJsonCleartextKeyset(keyset_filename);
if (!keyset_handle.ok()) {
std::clog << "Failed to read json keyset";
return;
}
// Get the primitive.
StatusOr<std::unique_ptr<Aead>> aead =
(*keyset_handle)
->GetPrimitive<crypto::tink::Aead>(
crypto::tink::ConfigGlobalRegistry());
if (!aead.ok()) {
std::clog << "Failed to get primitive";
return;
}
// Instantiate the enifd.
hsdpexperiments::InlineInstallData iid;
iid.set_timestamp_ms(std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count());
iid.set_target_package_name("<TARGET_PACKAGE_NAME>");
iid.set_caller_package_name("<CALLER_PACKAGE_NAME>");
iid.set_ad_network_id("<SDK_ID>");
// Compute the output.
StatusOr<std::string> encrypt_result =
(*aead)->Encrypt(iid.SerializeAsString(), associated_data);
if (!encrypt_result.ok()) {
std::clog << "Failed to encrypt Inline Install Data";
return;
}
const std::string& output = encrypt_result.value();
std::string enifd;
absl::WebSafeBase64Escape(output, &enifd);
std::clog << "enifd: " << enifd << '\n';
}
} // namespace tink_cc_examples
int main(int argc, char** argv) {
absl::ParseCommandLine(argc, argv);
std::string keyset_filename = absl::GetFlag(FLAGS_keyset_filename);
std::string associated_data = absl::GetFlag(FLAGS_associated_data);
std::clog << "Using keyset from file " << keyset_filename
<< " to AEAD-encrypt inline install data with associated data '"
<< associated_data << "'." << '\n';
tink_cc_examples::AeadCli(keyset_filename, associated_data);
return 0;
}
এই কোডটি টিঙ্ক ডক্স-এ থাকা একটি নমুনা থেকে অভিযোজিত করা হয়েছে।