Skip to main content
Power Automate
    • Connectors
    • Templates
    • Digital process automation
    • Robotic process automation
    • Business process automation
    • Process advisor
    • AI Builder
  • Pricing
  • Partners
    • Blog
    • Documentation
    • Roadmap
    • Self-paced learning
    • Webinar
    • Business process and workflow automation topics
    • Overview
    • Issues
    • Give feedback
    • Overview
    • Forums
    • Galleries
    • Submit ideas
    • User groups
    • Register
    • ·
    • Sign in
    • ·
    • Help
    Go To
    • Microsoft Power Automate Community
    • Welcome to the Community!
    • News & Announcements
    • Get Help with Power Automate
    • General Power Automate Discussion
    • Using Connectors
    • Building Flows
    • Using Flows
    • Power Automate Desktop
    • Process Advisor
    • AI Builder
    • Power Automate Mobile App
    • Translation Quality Feedback
    • Connector Development
    • Share, Chat, Discuss
    • Community Chat & Announcements
    • Off Topic Discussion
    • Power Platform Integration - Better Together!
    • Power Platform Integrations
    • Power Platform and Dynamics 365 Integrations
    • Galleries
    • Community Connections & How-To Videos
    • Webinars and Video Gallery
    • Power Automate Cookbook
    • 2021 MSBizAppsSummit Gallery
    • 2020 MSBizAppsSummit Gallery
    • 2019 MSBizAppsSummit Gallery
    • Ideas
    • Power Automate Ideas
    • Report Issues
    • I Found A Bug
    • Community Engagement
    • Community AMA
    • Community Blog
    • Power Automate Community Blog
    • Community Blog Topic Suggestions
    • Community Support
    • Community Accounts & Registration
    • Using the Community
    • Community Feedback
    cancel
    Turn on suggestions
    Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
    Showing results for 
    Search instead for 
    Did you mean: 
    • Microsoft Power Automate Community
    • Galleries
    • Power Automate Cookbook
    • Parse a bearer token using Flow

    Parse a bearer token using Flow

    01-08-2020 11:12 AM

    Microsoft svarukala
    Microsoft
    4354 Views
    LinkedIn LinkedIn Facebook Facebook Twitter Twitter
    svarukala
    Microsoft svarukala
    Microsoft
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    Parse a bearer token using Flow

    ‎01-08-2020 11:12 AM

    A simple button (manual) flow that can parse a bearer token to extract details like:

    • Issuer
    • AppID
    • Audience
    • TokenSubject
    • TokenSender etc.

    Note that a HTTP based flow won't execute when you pass a bearer token in the Authorization header. You can send it as a normal POST body or a parameter instead and use that as a layer of security so that Flow can validate the token and only then execute.

    Preview file
    23 KB
    Parsebearertoken_20191217183437.zip
    Labels:
    • Labels:
    • Button flows
    Message 1 of 8
    4,354 Views
    5 Kudos
    Reply
    • All posts
    • Previous Topic
    • Next Topic
    liansc
    liansc
    Frequent Visitor
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎01-14-2021 01:56 AM

    Hi, I incorporated this in one of my flows to extract, decode, and parse a JWT and it works great, however I encounter an error with certain JWT values. After decodeBase64, I get an Unexpected character at the end of the nbf claim, so the ParseJSON action produces an error:

    The 'content' property of actions of type 'ParseJson' must be valid JSON. The provided value cannot be parsed: 'Unexpected character encountered while parsing number: �. Path 'nbf', line 1, position 426.'.

    The output of decodeBase64() is as follows, and it doesn't have a closing brace:

    {"iat":xxx,"ver":"xxx","appid":"xxx","sub":"xxx","appidacr":"x","acr":"x","tid":"xxx","sender":"xxx","oid":"xxx","iss":"xxx","aud":"xxx","exp":1610614832,"nbf":161061393�

    In other cases, it works fine. Any idea what could be wrong? Thanks.

    Message 2 of 8
    3,006 Views
    0 Kudos
    Reply
    liansc
    liansc
    Frequent Visitor
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎01-14-2021 03:46 AM

    Figured it out - decodeBase64() expects the input's length to be divisible by 4, so as a workaround, I just appended (one or more) '=' characters to my token before decoding. Works ok now.

    Message 3 of 8
    3,000 Views
    2 Kudos
    Reply
    svarukala
    Microsoft svarukala
    Microsoft
    In response to liansc
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎01-19-2021 04:40 PM

    @liansc looks like an edge case scenario, but good tshooting. 

    Message 4 of 8
    2,963 Views
    0 Kudos
    Reply
    Suga
    Suga
    New Member
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎03-11-2021 11:45 PM

    Hi @svarukala , I was trying to follow your steps, the decode does not work for the token i generated using Oauth2. Can you help me with that

     

    Unfortunately, i will not able to share the token value here. I can PM you if you can help me with fix the decode 

    Message 5 of 8
    2,687 Views
    0 Kudos
    Reply
    svarukala
    Microsoft svarukala
    Microsoft
    In response to Suga
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎03-12-2021 06:31 AM

    @Suga can you share the error that you are seeing? Are you sure that you are not seeing the same error that @liansc reported above in the comments?

    Message 6 of 8
    2,672 Views
    0 Kudos
    Reply
    vincenzos1984_1
    vincenzos1984_1 Helper II
    Helper II
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎04-13-2021 03:30 PM

    i have used your flow and i have an error:

    Unable to process template language expressions in action 'decode_bearer' inputs at line '1' and column '3440': 'The template language function 'decodeBase64' was invoked with a parameter that is not valid. The value cannot be decoded from base64 representation.'.


    Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IlJmS0k2aDJ1aHhwNnJId3V4NzlVY0ZoVnZxdyIsIng1dCI6IlJmS0k2aDJ1aHhwNnJId3V4NzlVY0ZoVnZxdyIsImlzc2xvYyI6IkFNNlBSMDdNQjUxOTIiLCJzcWlkIjo2Mzc1MzUyNjQ4MzQwNjQyNTh9.eyJpYXQiOjE2MTgzNTE2MDEsInZlciI6IlNUSS5FeHRlcm5hbEFjY2Vzc1Rva2VuLlYxIiwiYXBwaWQiOiI0OGFmMDhkYy1mNmQyLTQzNWYtYjJhNy0wNjlhYmQ5OWMwODYiLCJzdWIiOiJhZG1pbkB2c2F2YW5hZGVsYWIub25taWNyb3NvZnQuY29tIiwiYXBwaWRhY3IiOiIyIiwiYWNyIjoiMCIsInRpZCI6IjAwNTUyZGM4LTdjYTEtNDZhYy1hZTI0LTFkN2IzNjViMmRkNyIsInNlbmRlciI6ImFkbWluQHZzYXZhbmFkZWxhYi5vbm1pY3Jvc29mdC5jb20iLCJvaWQiOiIwNmQ0NWZjNS1mMTcyLTQxOGYtYjMwMi1jZDQ3YTJiODAyMjEiLCJpc3MiOiJodHRwczovL3N1YnN0cmF0ZS5vZmZpY2UuY29tL3N0cy8iLCJhdWQiOiJodHRwczovL3Byb2QtNDgud2VzdGV1cm9wZS5sb2dpYy5henVyZS5jb20iLCJleHAiOjE2MTgzNTI1MDEsIm5iZiI6MTYxODM1MTYwMX0.pbR-CcJPjL49QxB8jkKvqDQ9P4OeWm99LQMw5wGExRYahqdThO9NnEfypbyg0-gnYCMJtkxCXh7IuWgYmOBR0ksGk8vFxLOyJfjhYB1iiARMLJ30_JFh3lJo1Q__ZGvNI8UzjM6gNQ3aMWJNTcdCDL0zOLOHV9octEtMQREdGJ1eDFbzi1APSDl1ugasj4q9AP-MJmtIIdUa7MA2BcAy-a6sXIZ8IR0P-x4jfNqT72laMS4pXgIaiSvi2uPuESNYrd_jotZy2zHf35s60fXkjCfI57bbgHZxg6mjAB_EHcBEzPRrWDL5vOmfvFmSZNkoniaroQ9cSwwuC7OCWp-5GA

    Message 7 of 8
    2,359 Views
    0 Kudos
    Reply
    vincenzos1984_1
    vincenzos1984_1 Helper II
    Helper II
    In response to liansc
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎04-14-2021 05:36 AM

    thanks a lot solved adding (one or more) '=' 

    Message 8 of 8
    2,337 Views
    1 Kudo
    Reply

    Power Platform

    • Overview
    • Power BI
    • Power Apps
    • Power Automate
    • Power Virtual Agents

    • Sign up free
    • Sign in

    Browse

    • Templates
    • Connectors
    • Partners

    Downloads

    • Mobile
    • Gateway

    Learn

    • Documentation
    • Learn
    • Support
    • Community
    • Give feedback
    • Blog
    • Pricing

    • © 2022 Microsoft
    • Contact us
    • Trademarks
    • Privacy & cookies
    • Manage cookies
    • Terms of use
    • Terms & conditions