Skip to main content

"How to Create Stunning AI-Generated Images with Top AI Tools"

  Netizens are creating a trend with AI created photos and videos. There are some apps available for editing and recreating photos. Let's see that.. Lensa AI The filters in this app can make even an ordinary picture look amazing. It includes AI tools like magic avatars, sky replacement, face retouching, back and blur. Picsart It is an all-in-one photo editing app. Many facilities like background removal, enhance, replace an object, image generation are available. Some can be used for free. Fotor This app offers facilities like AI Baby Generator, AI Cartoonizer, AI Photo Announcer, AI Art Generator, Remove Objects, Image Upscaler. Apart from this, you can also know how your appearance will be in the future. PhotoDirector It has tons of effects to bring your photos to life with animation tool. Most of them are free. Along with animation, tools like AI Sky Replacement, AI Anime Filter, Avatar and thousands of stickers can be used. Remini Features like clothes swaps are very entertaini...

Access Secrets from Google Secret Manager using Apps Script


 To access secrets from Google Secret Manager using Google Apps Script, you will need to follow a series of steps involving setting up the Secret Manager, enabling the necessary API, and writing the appropriate Apps Script code.

1. Set Up Google Secret Manager

  1. Create a Secret:
    • Go to the Google Cloud Console.
    • Navigate to the Secret Manager (you can find it under Security or use the search bar).
    • Click on "Create Secret."
    • Follow the prompts to name your secret and add the secret value.

2. Enable Google Secret Manager API

  1. Enable the API:
    • In the Google Cloud Console, go to the API & Services Dashboard.
    • Click on "Enable APIs and Services."
    • Search for "Secret Manager API" and enable it.

3. Set Up Authentication

  1. Create a Service Account:

    • In the Google Cloud Console, go to IAM & Admin > Service Accounts.
    • Click on "Create Service Account."
    • Follow the prompts to create a service account. Assign it the "Secret Manager Secret Accessor" role.
  2. Create a JSON Key:

    • After creating the service account, go to the "Keys" section.
    • Click on "Add Key" and choose "Create New Key."
    • Select "JSON" and download the key file. Save it securely.

4. Write Google Apps Script Code

  1. Upload the JSON Key to Google Drive:

    • Upload the JSON key file to your Google Drive.
  2. Use the JSON Key in Apps Script:

    • Write the following Apps Script code to access the secret:
function getSecret() { var secretName = "projects/YOUR_PROJECT_ID/secrets/YOUR_SECRET_NAME/versions/latest"; var keyFileId = "YOUR_JSON_KEY_FILE_ID"; // File ID of the JSON key in Google Drive var keyFile = DriveApp.getFileById(keyFileId).getBlob().getDataAsString(); var key = JSON.parse(keyFile); var url = "https://secretmanager.googleapis.com/v1/" + secretName + ":access"; var response = UrlFetchApp.fetch(url, { method: "GET", headers: { "Authorization": "Bearer " + getAccessToken(key) } }); var secretPayload = JSON.parse(response.getContentText()).payload.data; var secret = Utilities.base64Decode(secretPayload); var secretString = new TextDecoder().decode(secret); Logger.log(secretString); return secretString; } function getAccessToken(key) { var jwtHeader = { "alg": "RS256", "typ": "JWT" }; var jwtClaimSet = { "iss": key.client_email, "scope": "https://www.googleapis.com/auth/cloud-platform", "aud": "https://oauth2.googleapis.com/token", "exp": Math.floor(Date.now() / 1000) + 3600, "iat": Math.floor(Date.now() / 1000) }; var signedJwt = createSignedJwt(jwtHeader, jwtClaimSet, key.private_key); var tokenResponse = UrlFetchApp.fetch("https://oauth2.googleapis.com/token", { method: "POST", payload: { "grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer", "assertion": signedJwt } }); var token = JSON.parse(tokenResponse.getContentText()).access_token; return token; } function createSignedJwt(header, claimSet, privateKey) { var base64Header = Utilities.base64EncodeWebSafe(JSON.stringify(header)); var base64ClaimSet = Utilities.base64EncodeWebSafe(JSON.stringify(claimSet)); var toSign = base64Header + "." + base64ClaimSet; var signature = Utilities.computeRsaSha256Signature(toSign, privateKey); var base64Signature = Utilities.base64EncodeWebSafe(signature); return toSign + "." + base64Signature; }

5.Run the Script

  • Save and run the getSecret function in your Apps Script project.
  • This function retrieves the secret value from Google Secret Manager and logs it.

Important Notes

  • Ensure your Google Apps Script project has access to the necessary scopes, particularly the Drive API.
  • The service account should have the appropriate permissions to access the secret in Secret Manager.
  • Securely handle and store your JSON key file to avoid unauthorized access.

By following these steps, you can access secrets from Google Secret Manager using Google Apps Script securely and efficiently

Comments

Popular posts from this blog

Sukanya Samriddhi Yojana-Hindi

 ### सुकन्या समृद्धि योजना (Sukanya Samriddhi Yojana) हिंदी में सुकन्या समृद्धि योजना भारत सरकार द्वारा शुरू की गई एक बचत योजना है, जिसका उद्देश्य माता-पिता को उनकी बेटियों के भविष्य की शिक्षा और विवाह के खर्चों के लिए बचत करने के लिए प्रोत्साहित करना है। "बेटी बचाओ, बेटी पढ़ाओ" अभियान के हिस्से के रूप में शुरू की गई, यह योजना आकर्षक ब्याज दरों और कर लाभ प्रदान करती है। यहाँ इस योजना की कुछ मुख्य विशेषताएं और लाभ दिए गए हैं: ### मुख्य विशेषताएं 1. **पात्रता**:    - यह खाता 10 वर्ष तक की आयु की बालिकाओं के लिए खोला जा सकता है।    - प्रत्येक बालिका के लिए केवल एक खाता खोला जा सकता है, और एक परिवार में अधिकतम दो खाते खोले जा सकते हैं। 2. **जमा सीमा**:    - न्यूनतम वार्षिक जमा राशि ₹250 है।    - अधिकतम जमा सीमा प्रति वित्तीय वर्ष ₹1.5 लाख है। 3. **ब्याज दर**:    - ब्याज दर सरकार द्वारा तिमाही आधार पर संशोधित की जाती है। यह आमतौर पर अन्य छोटी बचत योजनाओं की तुलना में अधिक होती है। 4. **अवधि**:    - खाता खोलने की तारीख से 21 वर्...

Sukanya Samriddhi Scheme -Post Office / Authorised Bank

 The Sukanya Samriddhi Scheme is a government-backed savings scheme in India, aimed at encouraging parents to save for their daughters' future education and marriage expenses. Launched as part of the "Beti Bachao, Beti Padhao" campaign, it offers attractive interest rates and tax benefits. Here are some key features and benefits of the Sukanya Samriddhi Scheme: ### Key Features 1. **Eligibility**:    - The account can be opened for a girl child up to the age of 10 years.    - Only one account per girl child is allowed, and a maximum of two accounts per family is permissible. 2. **Deposit Limits**:    - The minimum annual deposit is ₹250.    - The maximum deposit limit per financial year is ₹1.5 lakh. 3. **Interest Rate**:    - The interest rate is revised quarterly by the government. It has historically been higher compared to other small savings schemes. 4. **Tenure**:    - The account matures 21 years from the date of op...

సుకన్య సమృద్ధి యోజన

 ### సుకన్య సమృద్ధి యోజన (Sukanya Samriddhi Yojana)  సుకన్య సమృద్ధి యోజన భారత ప్రభుత్వమిచే ప్రవేశపెట్టబడిన ఒక మంచి పొదుపు పథకం, దీని ఉద్దేశ్యం అమ్మాయిల భవిష్యత్తు విద్య మరియు వివాహ ఖర్చుల కోసం తల్లిదండ్రులను పొదుపు చేయడానికి ప్రోత్సహించడం. "బేటీ బచావో, బేటీ పడావో" ప్రచారంలో భాగంగా ప్రారంభించబడిన ఈ పథకం ఆకర్షణీయమైన వడ్డీ రేట్లు మరియు పన్ను ప్రయోజనాలను అందిస్తుంది. ఈ పథకం యొక్క కొన్ని ముఖ్యాంశాలు మరియు ప్రయోజనాలు ఇక్కడ ఉన్నాయి: ### ముఖ్యాంశాలు 1. **అర్హత**:    - ఈ ఖాతా 10 సంవత్సరాల లోపు ఉన్న అమ్మాయిల కోసం తెరవబడుతుంది.    - ప్రతి అమ్మాయికి ఒక ఖాతా మాత్రమే అనుమతించబడుతుంది మరియు ఒక్క కుటుంబం రెండుకు మించి ఖాతాలు తెరవకూడదు. 2. **నివ్వాల్సిన మొత్తాలు**:    - కనీస వార్షిక జమ మొత్తం ₹250.    - గరిష్ట వార్షిక జమ పరిమితి ₹1.5 లక్షలు. 3. **వడ్డీ రేటు**:    - వడ్డీ రేటు ప్రభుత్వము ద్వారా ప్రతి త్రైమాసికం సవరించబడుతుంది. ఇది ఇతర చిన్న పొదుపు పథకాలతో పోల్చినపుడు ఎక్కువగానే ఉంటుంది. 4. **కాలపరిమితి**:    - ఖాతా తెరవబడిన తేదీ నుండి ...