Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      June 1, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      June 1, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      June 1, 2025

      How To Prevent WordPress SQL Injection Attacks

      June 1, 2025

      7 MagSafe accessories that I recommend every iPhone user should have

      June 1, 2025

      I replaced my Kindle with an iPad Mini as my ebook reader – 8 reasons why I don’t regret it

      June 1, 2025

      Windows 11 version 25H2: Everything you need to know about Microsoft’s next OS release

      May 31, 2025

      Elden Ring Nightreign already has a duos Seamless Co-op mod from the creator of the beloved original, and it’ll be “expanded on in the future”

      May 31, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Student Record Android App using SQLite

      June 1, 2025
      Recent

      Student Record Android App using SQLite

      June 1, 2025

      When Array uses less memory than Uint8Array (in V8)

      June 1, 2025

      Laravel 12 Starter Kits: Definite Guide Which to Choose

      June 1, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Photobooth is photobooth software for the Raspberry Pi and PC

      June 1, 2025
      Recent

      Photobooth is photobooth software for the Raspberry Pi and PC

      June 1, 2025

      Le notizie minori del mondo GNU/Linux e dintorni della settimana nr 22/2025

      June 1, 2025

      Rilasciata PorteuX 2.1: Novità e Approfondimenti sulla Distribuzione GNU/Linux Portatile Basata su Slackware

      June 1, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Securely Store API, Bearer and Auth Tokens with Platform Cache

    Securely Store API, Bearer and Auth Tokens with Platform Cache

    May 29, 2025

    Imagine you are retrieving an API key/Bearer token from an external system to make a new callout to another external system. But there is one issue: you cannot determine when the new callout will take place, so you need to store the token value somewhere in your org for later use. Probably you will be thinking of storing it in your custom object or custom metadata. But creating a separate object/metadata for such a case may not be an efficient way. Then what? I think this is where Platform Cache helps you. Platform Cache provides temporary storage for such data in such cases. You can set up your platform cache by following the steps outlined in this trailhead. Here, I will explain how you can use the platform cache for this use case: I expect that you have already configured your platform cache in your dev org. Now suppose, you receive a bearer token from one API to pass into another callout after sometime, so you can store that access token in the Platform cache and avoid the hassle of creating a separate custom object/metadata or Custom Setting (Although you cannot update a Custom Metadata/Setting using Apex code).

    The Trailhead referenced in this article is crucial for understanding and setting up the platform cache. If you have not gone through the trailhead, then stop here and complete the trailhead first.

    How to Use Platform Cache to Fetch a Bearer Token

    How to fetch a bearer token and save it into the Platform cache using Apex:

    Picture1

    Now, you can fetch the bearer token from the Platform cache and use it in your next callout with the following code:

    Hostinger

    Picture2 Picture3

     

    Remember, Platform Cache provides temporary storage, and data can be evicted from it because of memory pressure. Platform Cache does not guarantee the determined lifetime of the value stored; therefore, it is better not to store any value with an extended validity or sensitive information.

    Although platform cache is used to improve performance by evading unnecessary repeated API calls, there are a few concerns about using the Platform cache.

    When Not to Use Platform Cache

    • If the value contains sensitive information
    • If the value has to be stored for the long term
    • If you need environment-specific secret management

    References

    External System used: https://www.reqres.in
    Technology used: Salesforce

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleHuman Biases – How Smart Teams Can Still Make Dumb Decisions
    Next Article The Urgent Call for Responsible AI: Why We Can’t Afford to Wait – Part 1

    Related Posts

    Artificial Intelligence

    Markus Buehler receives 2025 Washington Award

    June 1, 2025
    Artificial Intelligence

    LWiAI Podcast #201 – GPT 4.5, Sonnet 3.7, Grok 3, Phi 4

    June 1, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    3 easy ways to add AI Summarization to Conversation Intelligence tools

    Artificial Intelligence

    How to Fix Spotify ‘No PubKey’ Error on Ubuntu

    Linux

    Critical Flaw in Oracle Agile PLM Framework Exposes Sensitive Data: Patch Now

    Development

    The Ultimate Checklist for Building a Grocery Delivery App in 2024

    Development
    GetResponse

    Highlights

    Text Expander

    May 30, 2025

    Post Content Source: Read More 

    Tariffs

    Tariffs

    April 9, 2025

    Boost your laptop or Copilot+ PC with this monster Thunderbolt 4 USB dock from Satechi, a deal for $30 less this Cyber Monday / Black Friday

    December 1, 2024

    Google Chrome Beta Tests New DBSC Protection Against Cookie-Stealing Attacks

    April 3, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.