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

      Tiny Screens, Big Impact: The Forgotten Art Of Developing Web Apps For Feature Phones

      July 16, 2025

      Kong AI Gateway 3.11 introduces new method for reducing token costs

      July 16, 2025

      Native vs hybrid vs cross-platform: Resolving the trilemma

      July 16, 2025

      JetBrains updates Junie, Gemini API adds embedding model, and more – Daily News Digest

      July 16, 2025

      Cyberpunk 2077 Update 2.3 is bringing more vehicle customization, photo mode options, and one amazing new feature — launching this week

      July 16, 2025

      The cheapest place to get my games just got even cheaper — get an extra 10% off while you can

      July 16, 2025

      Destiny 2: The Edge of Fate reviews open ‘Mixed’ on Steam, with a player count only a fraction of The Final Shape’s — I’m surprised it’s this low after a new expansion

      July 16, 2025

      A rare opportunity is here to get an HP gaming laptop for only $500 — NVIDIA RTX graphics and a 144Hz display at a bargain price

      July 16, 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

      The details of TC39’s last meeting

      July 16, 2025
      Recent

      The details of TC39’s last meeting

      July 16, 2025

      Vector Search Embeddings and RAG

      July 16, 2025

      Python Meets Power Automate: Trigger via URL

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

      Cyberpunk 2077 Update 2.3 is bringing more vehicle customization, photo mode options, and one amazing new feature — launching this week

      July 16, 2025
      Recent

      Cyberpunk 2077 Update 2.3 is bringing more vehicle customization, photo mode options, and one amazing new feature — launching this week

      July 16, 2025

      The cheapest place to get my games just got even cheaper — get an extra 10% off while you can

      July 16, 2025

      Destiny 2: The Edge of Fate reviews open ‘Mixed’ on Steam, with a player count only a fraction of The Final Shape’s — I’m surprised it’s this low after a new expansion

      July 16, 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:

    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

    Experiment with Gemini 2.0 Flash native image generation

    July 16, 2025
    Artificial Intelligence

    Introducing Gemma 3

    July 16, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    Windows 11 new Start menu won’t let you create new Categories, clubs apps as “Other”

    Operating Systems

    The best Xbox controller money can buy just got even better thanks to one update from Razer — especially if you’re also a PC gamer

    News & Updates

    CVE-2025-5018 – WordPress Hive Support Plugin Unauthenticated Data Manipulation Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Local Pan-Privacy for Federated Analytics

    Machine Learning

    Highlights

    Nvidia launches NeMo software tools to help enterprises build custom AI agents

    April 23, 2025

    The agentic AI software is meant to complement human work to improve productivity, the company…

    Hardinfo2 offers system information and benchmark for Linux systems

    May 16, 2025

    CVE-2025-6436 – “Mozilla Firefox Memory Corruption Vulnerability”

    June 24, 2025

    CVE-2025-4325 – MRCMS Cross-Site Scripting Vulnerability

    May 6, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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