Similar to the service account workflow , the single user authentication flow makes use of the authorization and user management features offered by the Google Ads UI to grant the app access to all the necessary accounts. This authentication workflow has two steps:
- আপনি একজন ব্যবহারকারীকে সেই সমস্ত গুগল অ্যাডস অ্যাকাউন্টে অ্যাক্সেস দেন যা অ্যাপটি দ্বারা পরিচালিত হবে।
- ব্যবহারকারী আপনার অ্যাপকে তার পক্ষ থেকে তার গুগল অ্যাডস অ্যাকাউন্টগুলো পরিচালনা করার অনুমোদন দেন, যার ফলে অ্যাপটি সমস্ত গুগল অ্যাডস অ্যাকাউন্টে অ্যাক্সেস পায়।
যেহেতু এখানে কেবল একজন ব্যবহারকারী জড়িত, তাই আপনি নিজের OAuth 2.0 ব্যবহারকারী প্রমাণীকরণ ফ্লো তৈরি করার পরিবর্তে gcloud CLI অথবা GenerateUserCredential কোড উদাহরণের মতো টুলগুলোর উপর নির্ভর করতে পারেন।
A related use case for this workflow is when your accounts can be accessed through a handful of user logins (for example, 3-4 users), so the development effort to build a full-blown OAuth user authentication workflow isn't justified when compared to the effort for obtaining authorization for 3-4 users using a command line tool such as gcloud CLI.
অসুবিধা
সার্ভিস অ্যাকাউন্ট ওয়ার্কফ্লোর তুলনায় এই ফ্লোটির কয়েকটি অসুবিধা রয়েছে:
- User authentication workflow requires you to create an OAuth 2.0 client ID and secret in the Google Cloud Console, which requires more configuration steps than creating a service account and key.
- আপনার অ্যাপটিকে একটি অতিরিক্ত গুগল ক্লাউড অ্যাপ যাচাইকরণ প্রক্রিয়ার মধ্য দিয়ে যেতে হতে পারে।
- If the authorized user leaves the team or company, then your app may stop working if you remove the user from your accounts or disable the user account. Service accounts are not tied to individual users, so this risk is avoided.
- The user authorizing the Google Ads account should take extra precautions such as enabling 2 factor authentication to defend against their Google Account getting compromised due to getting compromised due to poor security, malware, or phishing. Service accounts are less vulnerable to this issue since some of these modes of attack don't directly apply to them.
পরিচয়পত্র তৈরি করুন
Follow the instructions to configure an OAuth consent screen for your application and add
https://www.googleapis.com/auth/adwordsas an OAuth 2.0 scope. See Setting up your OAuth consent screen for details.Create a client ID and client secret by following the instructions . Once you create the OAuth 2.0 client, download the client's JSON file by first clicking its Download OAuth client icon and then the DOWNLOAD JSON button on the following screen. Save the file as
credentials.json.Identify a user account that has access to all the Google Ads accounts you want to manage using your app. If there are accounts with missing access, then follow the instructions to grant the necessary access.
gcloud CLI ডাউনলোড এবং ইনস্টল করুন । ইনস্টল হয়ে গেলে, কমান্ড লাইন প্রম্পট থেকে
gcloud versionকমান্ডটি চালিয়ে টুলটি সঠিকভাবে কাজ করছে কিনা তা যাচাই করুন। আউটপুটটি নিম্নলিখিতের মতো দেখতে হতে পারে।:~$ gcloud version Google Cloud SDK 492.0.0 alpha 2024.09.06 beta 2024.09.06 bq 2.1.8 bundled-python3-unix 3.11.9 core 2024.09.06 enterprise-certificate-proxy 0.3.2 gcloud-crc32c 1.0.0 gsutil 5.30
gcloud CLI টুলটি চালিয়ে একটি OAuth 2.0 রিফ্রেশ টোকেন তৈরি করুন:
gcloud auth application-default
login --scopes=https://www.googleapis.com/auth/adwords,https://www.googleapis.com/auth/cloud-platform
--client-id-file=<path_to_credentials.json>credentials.jsonফাইলটি পূর্ববর্তী ধাপের।The
gcloudcommand opens a Google Account login window in a new browser window and takes you through the OAuth 2.0 authentication steps. Make sure you sign in as the user you selected from the previous steps. If your app is unverified , you might see a warning screen. In such cases, it's safe to click the Show Advanced link and click the Go to PROJECT_NAME (unverified) option.
After you verify the scopes, click the Continue button to grant the permission. The browser navigates to
https://cloud.google.com/sdk/auth_success, indicating that the authentication was successful. The page displays the following message:Authorization code granted. Close this tab.gcloudকমান্ডটি নিম্নলিখিত বার্তাটি প্রিন্ট করে:Credentials saved to file: [/****/.config/gcloud/application_default_credentials.json]এখন
application_default_credentials.jsonফাইলটি খুলুন। এর বিষয়বস্তু নিচের মতো হওয়া উচিত:{ "account": "", "client_id": "******.apps.googleusercontent.com", "client_secret": "******", "refresh_token": "******", "type": "authorized_user", "universe_domain": "googleapis.com" }
ক্লায়েন্ট লাইব্রেরি কনফিগারেশন
আপনার ক্লায়েন্ট লাইব্রেরি কীভাবে কনফিগার করবেন তার নির্দেশাবলীর জন্য আপনার প্রোগ্রামিং ভাষার সাথে সম্পর্কিত ট্যাবটি নির্বাচন করুন।
জাভা
আপনার ads.properties ফাইলে নিম্নলিখিত কীগুলি কনফিগার করুন।
api.googleads.clientId=INSERT_CLIENT_ID_HERE api.googleads.clientSecret=INSERT_CLIENT_SECRET_HERE api.googleads.refreshToken=INSERT_REFRESH_TOKEN_HERE api.googleads.loginCustomerId=INSERT_LOGIN_CUSTOMER_ID_HERE
অতিরিক্ত বিকল্পগুলির জন্য কনফিগারেশন গাইড দেখুন।
.NET
আপনি যে ব্যবহারকারীর অ্যাকাউন্টে এপিআই কল করছেন, তার কাছ থেকে প্রাপ্ত ক্রেডেনশিয়াল ব্যবহার করে রানটাইমে আপনার GoogleAdsClient ইনস্ট্যান্সটি ইনিশিয়ালাইজ করতে পারেন।
GoogleAdsConfig config = new GoogleAdsConfig() { OAuth2Mode = OAuth2Flow.APPLICATION, OAuth2ClientId = "INSERT_OAUTH2_CLIENT_ID", OAuth2ClientSecret = "INSERT_OAUTH2_CLIENT_SECRET", OAuth2RefreshToken = "INSERT_OAUTH2_REFRESH_TOKEN", ... }; GoogleAdsClient client = new GoogleAdsClient(config);
অতিরিক্ত বিকল্পগুলির জন্য কনফিগারেশন গাইড দেখুন।
পাইথন
আপনার google-ads.yaml ফাইলে নিম্নলিখিত কীগুলি কনফিগার করুন।
client_id: INSERT_OAUTH2_CLIENT_ID_HERE client_secret: INSERT_OAUTH2_CLIENT_SECRET_HERE refresh_token: INSERT_REFRESH_TOKEN_HERE login_customer_id: INSERT_LOGIN_CUSTOMER_ID_HERE
অতিরিক্ত বিকল্পগুলির জন্য কনফিগারেশন গাইড দেখুন।
পিএইচপি
আপনার google_ads_php.ini ফাইলে নিম্নলিখিত কীগুলি কনফিগার করুন।
[GOOGLE_ADS] loginCustomerId = "INSERT_LOGIN_CUSTOMER_ID_HERE" [OAUTH2] clientId = "INSERT_OAUTH2_CLIENT_ID_HERE" clientSecret = "INSERT_OAUTH2_CLIENT_SECRET_HERE" refreshToken = "INSERT_OAUTH2_REFRESH_TOKEN_HERE"
অতিরিক্ত বিকল্পগুলির জন্য কনফিগারেশন গাইড দেখুন।
রুবি
আপনার google_ads_config.rb ফাইলে নিম্নলিখিত কীগুলি কনফিগার করুন।
Google::Ads::GoogleAds::Config.new do |c| c.client_id = 'INSERT_CLIENT_ID_HERE' c.client_secret = 'INSERT_CLIENT_SECRET_HERE' c.refresh_token = 'INSERT_REFRESH_TOKEN_HERE' c.developer_token = 'INSERT_DEVELOPER_TOKEN_HERE' c.login_customer_id = 'INSERT_LOGIN_CUSTOMER_ID_HERE' end
অতিরিক্ত বিকল্পগুলির জন্য কনফিগারেশন গাইড দেখুন।
পার্ল
আপনার googleads.properties ফাইলে নিম্নলিখিত কীগুলি কনফিগার করুন।
clientId=INSERT_OAUTH2_CLIENT_ID_HERE clientSecret=INSERT_OAUTH2_CLIENT_SECRET_HERE refreshToken=INSERT_OAUTH2_REFRESH_TOKEN_HERE loginCustomerId=INSERT_LOGIN_CUSTOMER_ID_HERE
অতিরিক্ত বিকল্পগুলির জন্য কনফিগারেশন গাইড দেখুন।
কার্ল
প্রথমে একটি HTTP ক্লায়েন্ট ব্যবহার করে একটি OAuth 2.0 অ্যাক্সেস টোকেন সংগ্রহ করুন। এই নির্দেশিকায় curl কমান্ড ব্যবহার করা হয়েছে।
curl \ --data "grant_type=refresh_token" \ --data "client_id=CLIENT_ID" \ --data "client_secret=CLIENT_SECRET" \ --data "refresh_token=REFRESH_TOKEN" \ https://www.googleapis.com/oauth2/v3/token
You can now use the access token in your API calls. The following example shows how to run a campaign report using the GoogleAdsService.SearchStream method to retrieve the campaigns in your account. This guide doesn't cover the details of reporting .
curl -i -X POST https://googleads.googleapis.com/v24/customers/CUSTOMER_ID/googleAds:searchStream \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ACCESS_TOKEN" \ -H "developer-token: DEVELOPER_TOKEN" \ -H "login-customer-id: LOGIN_CUSTOMER_ID" \ --data-binary "@query.json"
query.json ফাইলের বিষয়বস্তু নিম্নরূপ:
{ "query": "SELECT campaign.id, campaign.name, campaign.network_settings.target_content_network FROM campaign ORDER BY campaign.id" }