আপনি Google Photos Library API-এর জন্য লিগ্যাসি ডকুমেন্টেশন দেখছেন।
জাভা ক্লায়েন্ট লাইব্রেরি দিয়ে শুরু করুন
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
Java ক্লায়েন্ট লাইব্রেরির সাথে Google Photos Library API ব্যবহার শুরু করতে, আপনাকে আপনার ডেভেলপমেন্ট পরিবেশে ক্লায়েন্ট লাইব্রেরি সেট আপ করতে হবে। আপনি এটি করার আগে, Google API কনসোলের মাধ্যমে API সক্ষম করে এবং একটি OAuth 2.0 ক্লায়েন্ট আইডি সেট আপ করে আপনার প্রকল্পটি কনফিগার করুন ৷
আপনার অ্যাপ্লিকেশানটি Google Photos ব্যবহারকারীর হয়ে Google Photos-এর সাথে ইন্টারঅ্যাক্ট করে৷ উদাহরণস্বরূপ, আপনি যখন কোনো ব্যবহারকারীর Google Photos লাইব্রেরিতে অ্যালবাম তৈরি করেন বা কোনো ব্যবহারকারীর Google Photos অ্যাকাউন্টে মিডিয়া আইটেম আপলোড করেন, তখন ব্যবহারকারী OAuth 2.0 প্রোটোকলের মাধ্যমে এই API অনুরোধগুলি অনুমোদন করে।
OAuth 2.0 ক্লায়েন্ট আইডি আপনার অ্যাপ্লিকেশন ব্যবহারকারীদের সাইন ইন, প্রমাণীকরণ এবং এর মাধ্যমে লাইব্রেরি API ব্যবহার করার অনুমতি দেয়। লাইব্রেরি API পরিষেবা অ্যাকাউন্ট সমর্থন করে না; এই API ব্যবহার করতে, ব্যবহারকারীদের অবশ্যই একটি বৈধ Google অ্যাকাউন্টে সাইন ইন করতে হবে৷
API সক্ষম করুন
আপনি লাইব্রেরি API ব্যবহার করার আগে, আপনাকে অবশ্যই আপনার প্রকল্পের জন্য এটি সক্ষম করতে হবে৷
- Google API কনসোলে যান।
- মেনু বার থেকে, একটি প্রকল্প নির্বাচন করুন বা একটি নতুন প্রকল্প তৈরি করুন৷
- Google API লাইব্রেরি খুলতে, নেভিগেশন মেনু থেকে, APIs & Services > Library নির্বাচন করুন।
- "Google Photos Library API" অনুসন্ধান করুন। সঠিক ফলাফল নির্বাচন করুন এবং সক্রিয় ক্লিক করুন।
একটি OAuth 2.0 ক্লায়েন্ট আইডি অনুরোধ করুন
একটি OAuth ক্লায়েন্ট আইডি অনুরোধ করতে এবং আপনার অ্যাপ্লিকেশনের জন্য এটি কনফিগার করতে নীচের পদক্ষেপগুলি অনুসরণ করুন৷ এই উদাহরণটি এমন একটি অ্যাপ্লিকেশন ব্যবহার করে যেখানে সমগ্র OAuth প্রবাহ সার্ভার-সাইড পরিচালনা করা হয়, যেমন আমাদের নমুনাগুলির মধ্যে একটি। অন্যান্য বাস্তবায়ন পরিস্থিতির জন্য সেটআপ প্রক্রিয়া পরিবর্তিত হতে পারে।
- Google API কনসোলে যান এবং আপনার প্রকল্প নির্বাচন করুন।
- মেনু থেকে, APIs & Services > Credentials নির্বাচন করুন।
- শংসাপত্র পৃষ্ঠায়, শংসাপত্র তৈরি করুন > OAuth ক্লায়েন্ট আইডি ক্লিক করুন।
- আপনার আবেদনের ধরন নির্বাচন করুন। এই উদাহরণে, অ্যাপ্লিকেশনের ধরন হল ওয়েব অ্যাপ্লিকেশন ।
যেখান থেকে আপনার অ্যাপকে Google API গুলি অ্যাক্সেস করার অনুমতি দেওয়া হয়েছে তা নিম্নরূপ নিবন্ধন করুন:
- ক্লায়েন্ট আইডি সনাক্ত করতে, একটি নাম লিখুন।
অনুমোদিত জাভাস্ক্রিপ্ট অরিজিন ফিল্ডে, আপনার অ্যাপের মূল লিখুন। এই ক্ষেত্রটি ওয়াইল্ডকার্ডের অনুমতি দেয় না।
আপনার অ্যাপটিকে বিভিন্ন প্রোটোকল, ডোমেন বা সাবডোমেনে চালানোর অনুমতি দিতে আপনি একাধিক অরিজিন লিখতে পারেন। আপনি যে URLগুলি লিখছেন সেগুলিকে একটি OAuth অনুরোধ শুরু করার অনুমতি দেওয়া হয়েছে৷
নিম্নলিখিত উদাহরণ একটি স্থানীয় উন্নয়ন URL (আমাদের নমুনা localhost:8080
) এবং একটি উত্পাদন URL দেখায়।
http://localhost:8080
https://myproductionurl.example.com
অনুমোদিত পুনঃনির্দেশ URI ক্ষেত্র হল শেষ পয়েন্ট যা OAuth 2.0 সার্ভার থেকে প্রতিক্রিয়া গ্রহণ করে। সাধারণত, এটি আপনার বিকাশের পরিবেশকে অন্তর্ভুক্ত করে এবং আপনার অ্যাপ্লিকেশনে একটি পথ নির্দেশ করে।
http://localhost:8080/auth/google/callback
https://myproductionurl.example.com/auth/google/callback
তৈরি করুন ক্লিক করুন।
ফলস্বরূপ OAuth ক্লায়েন্ট ডায়ালগ থেকে, আপনার ক্লায়েন্ট কনফিগারেশন ধারণকারী JSON ফাইলটি ডাউনলোড করুন। আপনার ক্লায়েন্টের বিবরণ নিম্নলিখিতগুলি নিয়ে গঠিত:
- ক্লায়েন্ট আইডি
- ক্লায়েন্ট গোপন
এই JSON ফাইলটি পরে Java এর জন্য Google Auth লাইব্রেরি সেট আপ করতে ব্যবহার করা হবে যা এই ক্লায়েন্ট লাইব্রেরির সাথে কাজ করে৷
আপনি লাইব্রেরি API অ্যাক্সেস করে এমন একটি সর্বজনীন অ্যাপ্লিকেশন চালু করার আগে, আপনার অ্যাপটি অবশ্যই Google দ্বারা পর্যালোচনা করা উচিত। আপনি যখন আপনার আবেদন পরীক্ষা করেন তখন একটি "অযাচাই করা অ্যাপ" বার্তাটি স্ক্রিনে উপস্থিত হয়, যতক্ষণ না এটি যাচাই করা হয়৷
ক্লায়েন্ট লাইব্রেরি সেট আপ করুন
জাভা ক্লায়েন্ট লাইব্রেরি আপনার জন্য সমস্ত ব্যাকএন্ড API কল পরিচালনা করে এবং কিছু সাধারণ API কাজের জন্য কোড নমুনা সহ কাজ করার জন্য বন্ধুত্বপূর্ণ বস্তুগুলিকে প্রকাশ করে। প্রথমত, GitHub থেকে নির্ভরতা সহ Java এর জন্য Google Photos Library API ক্লায়েন্ট লাইব্রেরি ডাউনলোড এবং ইনস্টল করুন। তারপর, Java এর জন্য আপনার OAuth2 শংসাপত্র সেট আপ করুন৷
ডাউনলোড অপশন
ক্লায়েন্ট লাইব্রেরি ডাউনলোড করার জন্য এখানে কিছু বিকল্প রয়েছে:
গ্রেডেল নির্ভরতা:
Gradle এর সাথে এই লাইব্রেরিটি ব্যবহার করতে, আপনার build.gradle
ফাইলে নিম্নলিখিত নির্ভরতা যোগ করুন।
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.photos.library:google-photos-library-client:1.7.3'
}
মাভেন নির্ভরতা:
Maven এর সাথে এই লাইব্রেরিটি ব্যবহার করতে, আপনার Maven pom.xml
ফাইলে নিম্নলিখিত যোগ করুন।
<dependency>
<groupId>com.google.photos.library</groupId>
<artifactId>google-photos-library-client</artifactId>
<version>1.7.3</version>
</dependency>
একটি রিলিজ ডাউনলোড করুন:
রিলিজ পৃষ্ঠায় জার ফাইল সহ প্রতিটি লাইব্রেরি রিলিজের জন্য বিভিন্ন শিল্পকর্ম রয়েছে।
সংগ্রহস্থল ক্লোন করুন:
আপনি যদি এই লাইব্রেরিতে পরিবর্তন বা অবদান রাখতে চান তবে এই পদ্ধতিটি ব্যবহার করুন, উদাহরণস্বরূপ, পুল অনুরোধ জমা দেওয়া, বা আপনি যদি আমাদের নমুনাগুলি চেষ্টা করতে চান। আপনি যখন সংগ্রহস্থলটি ক্লোন করবেন, তখন এই সংগ্রহস্থলের সমস্ত ফাইল ডাউনলোড হবে।
- কমান্ড প্রম্পটে
git clone https://github.com/google/java-photoslibrary.git
চালান। - আপনি একটি
java-photoslibrary
ডিরেক্টরি পাবেন। cd java-photoslibrary
চালিয়ে এটিতে নেভিগেট করুন। - আপনার IDE-তে
build.gradle
ফাইলটি খুলুন বা প্রজেক্ট তৈরি করতে কমান্ড প্রম্পটে ./gradlew assemble
চালান। উপলব্ধ কাজগুলি দেখতে ./gradlew tasks
দেখুন৷
Java এর জন্য আপনার OAuth2 শংসাপত্র সেট আপ করুন৷
এই ক্লায়েন্ট লাইব্রেরিটি Java এর জন্য Google Auth Library এর সাথে কাজ করে। আরও তথ্যের জন্য, Java এর জন্য Google API ক্লায়েন্ট লাইব্রেরির সাথে OAuth 2.0 ব্যবহার করুন দেখুন।
একটি PhotosLibraryClient
অবজেক্টের জন্য PhotoLibrarySettings
তৈরি করার সময় CredentialsProvider
এ আপনার ক্লায়েন্ট OAuth কনফিগারেশন নির্দিষ্ট করুন।
কিছু নমুনা চেষ্টা করুন
Java ক্লায়েন্ট লাইব্রেরি ব্যবহার করে আপনার প্রথম API কল করতে নীচের কোডটি চেষ্টা করুন।
// Set up the Photos Library Client that interacts with the API
PhotosLibrarySettings settings =
PhotosLibrarySettings.newBuilder()
.setCredentialsProvider(
FixedCredentialsProvider.create(/* Add credentials here. */))
.build();
try (PhotosLibraryClient photosLibraryClient =
PhotosLibraryClient.initialize(settings)) {
// Create a new Album with at title
Album createdAlbum = photosLibraryClient.createAlbum("My Album");
// Get some properties from the album, such as its ID and product URL
String id = album.getId();
String url = album.getProductUrl();
} catch (ApiException e) {
// Error during album creation
}
আপনার চেষ্টা করার জন্য GitHub-এ আরও নমুনা রয়েছে।
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-08-29 UTC-তে শেষবার আপডেট করা হয়েছে।
[[["সহজে বোঝা যায়","easyToUnderstand","thumb-up"],["আমার সমস্যার সমাধান হয়েছে","solvedMyProblem","thumb-up"],["অন্যান্য","otherUp","thumb-up"]],[["এতে আমার প্রয়োজনীয় তথ্য নেই","missingTheInformationINeed","thumb-down"],["খুব জটিল / অনেক ধাপ","tooComplicatedTooManySteps","thumb-down"],["পুরনো","outOfDate","thumb-down"],["অনুবাদ সংক্রান্ত সমস্যা","translationIssue","thumb-down"],["নমুনা / কোড সংক্রান্ত সমস্যা","samplesCodeIssue","thumb-down"],["অন্যান্য","otherDown","thumb-down"]],["2025-08-29 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eThe Google Photos Library API allows your application to interact with Google Photos on behalf of a user, requiring user authorization through OAuth 2.0.\u003c/p\u003e\n"],["\u003cp\u003eBefore using the API, you must enable it in the Google API Console and obtain an OAuth 2.0 client ID for your application.\u003c/p\u003e\n"],["\u003cp\u003eThe Java client library simplifies API interaction, and you can install it using Gradle, Maven, or by downloading a release from GitHub.\u003c/p\u003e\n"],["\u003cp\u003eTo authenticate your application, set up OAuth2 credentials using the Google Auth Library for Java and specify your client configuration in the \u003ccode\u003eCredentialsProvider\u003c/code\u003e.\u003c/p\u003e\n"]]],["To use the Google Photos Library API with Java, first enable the API in the Google API Console and create an OAuth 2.0 client ID, configuring authorized JavaScript origins and redirect URIs. Next, download the Java client library using Gradle, Maven, a direct download, or by cloning the GitHub repository. Finally, set up OAuth2 credentials using the Google Auth Library for Java, providing these in the `PhotosLibrarySettings` when initializing the `PhotosLibraryClient`. Then try out some samples.\n"],null,["# Get started with Java client library\n\nTo start using the Google Photos Library API with the Java client library, you will need to\n[set up the client library](#get-library) in your development environment.\nBefore you do that, [configure your project](#configure-app) by enabling the API\nvia the Google API Console and setting up an OAuth 2.0 client ID.\n\nYour application interacts with Google Photos on behalf of a\nGoogle Photos user. For instance, when you create albums in a user's\nGoogle Photos library or upload media items to a user's\nGoogle Photos account, the user authorizes these API requests via the\n[OAuth 2.0](/identity/protocols/OAuth2) protocol.\n\nThe OAuth 2.0 client ID allows your application users to sign in, authenticate,\nand thereby use the Library API. The Library API does not support\nservice accounts; to use this API, users must be signed in to a valid Google\nAccount.\n\nConfigure your app\n------------------\n\n### Enable the API\n\nBefore you can use the Library API, you must enable it for your project.\n\n1. Go to the [Google API Console](https://console.developers.google.com/apis/library).\n2. From the menu bar, select a project or create a new project.\n3. To open the Google API Library, from the Navigation menu, select **APIs \\& Services \\\u003e Library**.\n4. Search for \"Google Photos Library API\". Select the correct result and click **Enable**.\n\n### Request an OAuth 2.0 client ID\n\nFollow the steps below to request an OAuth client ID and configure it for your\napplication. This example uses an application where the entire OAuth flow is\nhandled server-side, such as the one in our samples. The setup process may vary\nfor other [implementation scenarios](/identity/protocols/OAuth2).\n\n1. Go to the [Google API Console](https://console.developers.google.com/apis/library) and select your project.\n2. From the menu, select **APIs \\& Services \\\u003e Credentials**.\n3. On the **Credentials** page, click **Create Credentials \\\u003e OAuth client ID**.\n4. Select your **Application type** . In this example, the application type is **Web application**.\n5. Register the origins from which your app is allowed to access the Google APIs\n as follows:\n\n 1. To identify the client ID, enter a name.\n 2. In the **Authorized JavaScript origins** field, enter the origin for your\n app. This field doesn't allow wildcards.\n\n You can enter multiple origins to allow your app to run on different\n protocols, domains, or subdomains. The URLs you enter are allowed to\n start an OAuth request.\n\n The following example shows a local development URL (our samples use\n `localhost:8080`) and a production URL. \n\n http://localhost:8080\n https://myproductionurl.example.com\n\n 3. The **Authorized redirect URI** field is the endpoint that receives\n responses from the OAuth 2.0 server. Typically, this includes your\n development environment and points to a path in your application.\n\n http://localhost:8080/auth/google/callback\n https://myproductionurl.example.com/auth/google/callback\n\n 4. Click **Create**.\n\n\u003c!-- --\u003e\n\n6. From the resulting OAuth client dialog, download the JSON file\n containing your client configuration. You client details consist of the\n following:\n\n - Client ID\n - Client secret\n\n This JSON file will be used later to [set up](#get-library)\n the Google Auth library for Java which works with this client library.\n\nBefore you can launch a public application that accesses the Library API,\nyour app must be reviewed by Google. An \"Unverified app\" message appears on the\nscreen when you test your application, until it is\n[verified](https://support.google.com/cloud/answer/7454865).\n\nSet up the client library\n-------------------------\n\nThe Java client library handles all the backend API calls for you, and exposes\nfriendly objects to work with, including code samples for some common API tasks.\nFirstly, download and install the Google Photos Library API client library for Java along\nwith the dependencies from [GitHub](https://github.com/google/java-photoslibrary).\nThen, set up your OAuth2 credentials for Java.\n\n### Download options\n\nHere are some options to download the client library:\n\n- **Gradle dependency:**\n\n To use this library with Gradle, add the following dependency to your\n `build.gradle` file. \n\n repositories {\n mavenCentral()\n }\n dependencies {\n compile 'com.google.photos.library:google-photos-library-client:1.7.3'\n }\n\n- **Maven dependency:**\n\n To use this library with Maven, add the following to your Maven `pom.xml`\n file. \n\n \u003cdependency\u003e\n \u003cgroupId\u003ecom.google.photos.library\u003c/groupId\u003e\n \u003cartifactId\u003egoogle-photos-library-client\u003c/artifactId\u003e\n \u003cversion\u003e1.7.3\u003c/version\u003e\n \u003c/dependency\u003e\n\n- **Download a release:**\n\n The [releases page](https://github.com/google/java-photoslibrary/releases)\n contains different artifacts for each library release, including jar files.\n- **Clone the repository:**\n\n Use this method if you want to alter or contribute to this library, for\n example, submitting pull requests, or if you wish to try our samples. When you\n clone the repository, **all** files in this repository will be downloaded.\n 1. Run `git clone https://github.com/google/java-photoslibrary.git` at the command prompt.\n 2. You'll get a `java-photoslibrary` directory. Navigate to it by running `cd java-photoslibrary`.\n 3. Open the `build.gradle` file in your IDE or run `./gradlew assemble` at the command prompt to build the project. See `./gradlew tasks` to see available tasks.\n\n### Set up your OAuth2 credentials for Java\n\nThis client library works with the [Google Auth Library for\nJava](https://github.com/google/google-auth-library-java). For more information,\nrefer to [Using OAuth 2.0 with the Google API Client Library for\nJava](https://developers.google.com/api-client-library/java/google-api-java-client/oauth2).\n\nSpecify your client OAuth configuration in the `CredentialsProvider` when\ncreating the `PhotoLibrarySettings` for a `PhotosLibraryClient` object.\n\nTry out some samples\n--------------------\n\nTry the code below to make your first API call using the Java client library. \n\n // Set up the Photos Library Client that interacts with the API\n PhotosLibrarySettings settings =\n PhotosLibrarySettings.newBuilder()\n .setCredentialsProvider(\n FixedCredentialsProvider.create(/* Add credentials here. */)) \n .build();\n\n try (PhotosLibraryClient photosLibraryClient =\n PhotosLibraryClient.initialize(settings)) {\n\n // Create a new Album with at title\n Album createdAlbum = photosLibraryClient.createAlbum(\"My Album\");\n\n // Get some properties from the album, such as its ID and product URL\n String id = album.getId();\n String url = album.getProductUrl();\n\n } catch (ApiException e) {\n // Error during album creation\n }\n\nThere are more [samples](https://github.com/google/java-photoslibrary/tree/master/sample)\non GitHub for you to try."]]