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

      CodeSOD: A Unique Way to Primary Key

      July 22, 2025

      BrowserStack launches Figma plugin for detecting accessibility issues in design phase

      July 22, 2025

      Parasoft brings agentic AI to service virtualization in latest release

      July 22, 2025

      Node.js vs. Python for Backend: 7 Reasons C-Level Leaders Choose Node.js Talent

      July 21, 2025

      The best CRM software with email marketing in 2025: Expert tested and reviewed

      July 22, 2025

      This multi-port car charger can power 4 gadgets at once – and it’s surprisingly cheap

      July 22, 2025

      I’m a wearables editor and here are the 7 Pixel Watch 4 rumors I’m most curious about

      July 22, 2025

      8 ways I quickly leveled up my Linux skills – and you can too

      July 22, 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 Intersection of Agile and Accessibility – A Series on Designing for Everyone

      July 22, 2025
      Recent

      The Intersection of Agile and Accessibility – A Series on Designing for Everyone

      July 22, 2025

      Zero Trust & Cybersecurity Mesh: Your Org’s Survival Guide

      July 22, 2025

      Execute Ping Commands and Get Back Structured Data in PHP

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

      A Tomb Raider composer has been jailed — His legacy overshadowed by $75k+ in loan fraud

      July 22, 2025
      Recent

      A Tomb Raider composer has been jailed — His legacy overshadowed by $75k+ in loan fraud

      July 22, 2025

      “I don’t think I changed his mind” — NVIDIA CEO comments on H20 AI GPU sales resuming in China following a meeting with President Trump

      July 22, 2025

      Galaxy Z Fold 7 review: Six years later — Samsung finally cracks the foldable code

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

    Development

    GPT-5 is Coming: Revolutionizing Software Testing

    July 22, 2025
    Development

    Win the Accessibility Game: Combining AI with Human Judgment

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

    The Future of Work: How AI Automation Is Revolutionizing Business Processes💼

    Web Development

    CVE-2025-32404 – RT-Labs P-Net OOB Write Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-49255 – ThemBay Ruza PHP Remote File Inclusion Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Microsoft threatens Windows 10 users to upgrade to be on the “right side of risk”

    News & Updates

    Highlights

    CVE-2025-4552 – ContiNew Admin Remote Unverified Password Change Vulnerability

    May 11, 2025

    CVE ID : CVE-2025-4552

    Published : May 12, 2025, 12:15 a.m. | 15 minutes ago

    Description : A vulnerability has been found in ContiNew Admin up to 3.6.0 and classified as problematic. Affected by this vulnerability is an unknown functionality of the file /dev-api/system/user/1/password. The manipulation leads to unverified password change. The attack can be launched remotely. The exploit has been disclosed to the public and may be used. The vendor was contacted early about this disclosure but did not respond in any way.

    Severity: 5.4 | MEDIUM

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    Rolling out Santa without freezing productivity: Tips from securing Figma’s fleet

    July 11, 2025

    Advancing Integration Between Drupal and MongoDB

    April 22, 2025

    Linux Data Recovery: How to Salvage Lost or Corrupted Files

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

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