Xero released their Oauth2.0 authenticated access to their API recently.
I am trying to write some flows to use this.
If I use Postman to generate the access code and then use it in flow, all works fine.
However the code needs to be refreshed every 30 minutes.
Running the token refresh call in Postman works fine, however it fails in Flow. "error": "unsupported_grant_type"
Post to https://identity.xero.com/connect/token
Header
"Authorization": "Basic Rjd..." - valid (checked) token
"Content-Type": "application/x-www-form-urlencoded"
The body of the http call is :-
{
"grant_type":"refresh_token",
"refresh_token":"0134e4a53c...",
"client_id":"F7B7...",
"client_secret":"GEfl..."
}
Can anyone shed any light on this please?
Hi @MartinHutchcpa ,
Could you please share a screenshot of the configuration of your flow?
Best regards,
Alice
Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Alice,
Here you go.
https://developer.xero.com/documentation/oauth2/auth-flow
This links to the refresh token syntax.
Did you ever get this working? I assume, if you are trying the refresh token, you had made the initial authentication work? Could you share that HTTP flow please?
Hi Luke,
I used Postman to get an initial token. The token is saved in a SharePoint list.
I have a flow that refreshes this token and saves it back to the list, this runs every 15 mins.
My flows then use this token from the SharePoint list to do their thing.
Hope this helps.
First off, thank you for replying to a post from 2020.
If my thinking is correct, the initial auth is performed via postman, and the PA flow retrieves the token saved in a sharepoint list?
I will explain my scenario. Google form time entry, which essentially was saved to a google sheet. I could extract the new rows and post to a sharepoint list, for time entry for a client. They have since moved to WorkFlowMax; i'm trying to create a similar process.
I would need to auth once per day to WFM via API and then POST add time. I imagine being in the position of auth once, and then refresh once per 24 hours, in order to post new data.
You worked out how to refresh such token via PowerA, referencing the original question?
Please can we keep the conversation going, I don't want to give up on my objective!
cheers
Luke
Hi Luke,
For Xero, the refresh PA is very simple, not sure about Google api endpoint though.
The Google Sheet aspect is easy, as there is a connector.
I have used PostMan for the first time, and have my access token now.
So I assume I can now bring that into PowerAutomate and work on the refresh cycle.
Once that is done, I can look at adding new time entry into work flow max.
Any pointers with the refresh flow for the token please?
Hi Luke,
I store my token in a Dynamics 365 table, although I have used Sharepoint in the past.
Awesome! Over on GIT is a Postman environment to import. Has all the workings of getting started with the Worflow max api - (GitHub - XeroAPI/workflowmax-postman-oauth2: A postman collection for use with WorkflowMax's API and...
So I can get to speed with interacting with the API via Postman and then bring my learnings into Power Automate.
cheers for the screenshot
@MartinHutchcpa , what is the redirect URL back to Power Automate that you use?
I didnt need one as I was working in private mode
Please could you post the breakdown of the HTTP flow, where you are refreshing the token.
I can't work out what should be in the Body and the Headers, however much I try I get Invalid_Client or Invalid_Request, where trying to refresh
Also, how is this string made up: Do I use the text as is, but replace the id and secret?
"Basic " + base64encode(client_id + ":" + client_secret)
Its this Authorization string which is throwing me now! I'm getting back Invalid_Client in PA. Could you give me some pointers please on how you have encoded it? I see at the first screen shot, its an expression with Basic and then I assume your base64encode string for client id and pass - how did you encode it?
OK I sorted it!!! Wow... talk about learning.
In the HTTP call I formed the body as form-data (reference from the way POSTMAN was forming the refresh request)
grant_type=refresh_token&refresh_Token=REFRESHTOKEN&client_id=CLIENTID&client_secret=CLIENTSECRET
No need for Authorization header and the base64encode string
Thanks @WillPage (Adding formData to HTTP Request - Power Platform Community (microsoft.com))
Thanks @MartinHutchcpa
Hi @LukePWilkins (et all)
Credit for your persistence here. I am trying to do exactly the same thing and can't seem to get past "{"error":"invalid_client"}".
I have successfully authenticated, refreshed tokens, retrieved invoices, and created invoices using Postman.
I have created a single flow with the three variables below and validated that the values are all correct and matching what is in Postman.
I have also tried formatting the body in JSON (noting to change content-type) however this returns 'invalid request'.
When I format the body exactly how you have set out, or copy/pasting from Postman both result in 'invalid client'.
My process to test this scenario is as follows:
Hoping you can shed some light on this for me. Here are some of my questions:
Here is the the output of my flow:
Any help would be greatly appreciated.
I have the access token and refresh token saved in a txt file on OneDrive. ClientID and Secret are hardcoded in the variables. RefreshToken, retrieves the refresh token from OneDrive, then its a POST to the API
Thanks for the response!
I ended up moving client_id, client_secret, xero-tenant-id, access_token, and refresh_token values to a Davaverse table.
I am 99.99999% sure these were all the exact same values that I had initialised as variables in my original flow.
Then the only change I made is that I noticed you had an uppercase T in the body for 'refresh_Token'.
The flow now works perfectly. I also added a Do Until status code = 200 so it will retry if it fails for any reason. The flow then updates the dataverse table with the new tokenset (access and refresh) details.
My flow now looks like this:
Thanks again for your response!
Do you have a typo in Grant_type refresh_tocken????
I have my flow scheduled to run every 29 mins and refresh the access token.
Glad you got it sorted! Two people extra now working with the API via Power Automate
@Nebulas , i'm going to look into storing data in the dataverse, which feels as much better option than onedrive TXT file!!!
As we continue to grow and learn together, it's important to reflect on the valuable insights we've shared. For today's #TuesdayTip, we're excited to take a moment to look back at the last 10 tips we've shared in case you missed any or want to revisit them. Thanks for your incredible support for this series--we're so glad it was able to help so many of you navigate your community experience! Getting Started in the Community An overview of everything you need to know about navigating the community on one page! Community Links: ○ Power Apps ○ Power Automate ○ Power Pages ○ Copilot Studio Community Ranks and YOU Have you ever wondered how your fellow community members ascend the ranks within our community? We explain everything about ranks and how to achieve points so you can climb up in the rankings! Community Links: ○ Power Apps ○ Power Automate ○ Power Pages ○ Copilot Studio Powering Up Your Community Profile Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile. Community Links: ○ Power Apps ○ Power Automate ○ Power Pages ○ Copilot Studio Community Blogs--A Great Place to Start There's so much you'll discover in the Community Blogs, and we hope you'll check them out today! Community Links: ○ Power Apps ○ Power Automate ○ Power Pages ○ Copilot Studio Unlocking Community Achievements and Earning Badges Across the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. Check out some details on Community badges--and find out more in the detailed link at the end of the article! Community Links: ○ Power Apps ○ Power Automate ○ Power Pages ○ Copilot Studio Blogging in the Community Interested in blogging? Everything you need to know on writing blogs in our four communities! Get started blogging across the Power Platform communities today! Community Links: ○ Power Apps ○ Power Automate ○ Power Pages ○ Copilot Studio Subscriptions & Notifications We don't want you to miss a thing in the community! Read all about how to subscribe to sections of our forums and how to setup your notifications! Community Links: ○ Power Apps ○ Power Automate ○ Power Pages ○ Copilot Studio Getting Started with Private Messages & Macros Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member! Community Links: ○ Power Apps ○ Power Automate ○ Power Pages ○ Copilot Studio Community User Groups Learn everything about being part of, starting, or leading a User Group in the Power Platform Community. Community Links: ○ Power Apps ○ Power Automate ○ Power Pages ○ Copilot Studio Update Your Community Profile Today! Keep your community profile up to date which is essential for staying connected and engaged with the community. Community Links: ○ Power Apps ○ Power Automate ○ Power Pages ○ Copilot Studio Thank you for being an integral part of our journey. Here's to many more Tuesday Tips as we pave the way for a brighter, more connected future! As always, watch the News & Announcements for the next set of tips, coming soon!
This month's Community Ambassador call is on May 9th at 9a & 3p PDT. Please keep an eye out in your private messages and Teams channels for your invitation. There are lots of exciting updates coming to the Community, and we have some exclusive opportunities to share with you! As always, we'll also review regular updates for User Groups, Super Users, and share general information about what's going on in the Community. Be sure to register & we hope to see all of you there!
We're pleased to share the April Community Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members. If you're new to the Community, please make sure to follow the latest News & Announcements and check out the Community on LinkedIn as well! It's the best way to stay up-to-date with all the news from across Microsoft Power Platform and beyond. COMMUNITY HIGHLIGHTS Check out the most active community members of the last month! These hardworking members are posting regularly, answering questions, kudos, and providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, follow these awesome community members to see what they do! Power AppsPower AutomateCopilot StudioPower PagesWarrenBelzDeenujialexander2523ragavanrajanLaurensMManishSolankiMattJimisonLucas001AmikcapuanodanilostephenrobertOliverRodriguestimlAndrewJManikandanSFubarmmbr1606VishnuReddy1997theMacResolutionsVishalJhaveriVictorIvanidzejsrandhawahagrua33ikExpiscornovusFGuerrero1PowerAddictgulshankhuranaANBExpiscornovusprathyooSpongYeNived_Nambiardeeksha15795apangelesGochixgrantjenkinsvasu24Mfon LATEST NEWS Business Applications Launch Event - On Demand In case you missed the Business Applications Launch Event, you can now catch up on all the announcements and watch the entire event on-demand inside Charles Lamanna's latest cloud blog. This is your one stop shop for all the latest Copilot features across Power Platform and #Dynamics365, including first-hand looks at how companies such as Lenovo, Sonepar, Ford Motor Company, Omnicom and more are using these new capabilities in transformative ways. Click the image below to watch today! Power Platform Community Conference 2024 is here! It's time to look forward to the next installment of the Power Platform Community Conference, which takes place this year on 18-20th September 2024 at the MGM Grand in Las Vegas! Come and be inspired by Microsoft senior thought leaders and the engineers behind the #PowerPlatform, with Charles Lamanna, Sangya Singh, Ryan Cunningham, Kim Manis, Nirav Shah, Omar Aftab and Leon Welicki already confirmed to speak. You'll also be able to learn from industry experts and Microsoft MVPs who are dedicated to bridging the gap between humanity and technology. These include the likes of Lisa Crosbie, Victor Dantas, Kristine Kolodziejski, David Yack, Daniel Christian, Miguel Félix, and Mats Necker, with many more to be announced over the coming weeks. Click here to watch our brand-new sizzle reel for #PPCC24 or click the image below to find out more about registration. See you in Vegas! Power Up Program Announces New Video-Based Learning Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram. These include a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the image below to find out more! UPCOMING EVENTS Microsoft Build - Seattle and Online - 21-23rd May 2024 Taking place on 21-23rd May 2024 both online and in Seattle, this is the perfect event to learn more about low code development, creating copilots, cloud platforms, and so much more to help you unleash the power of AI. There's a serious wealth of talent speaking across the three days, including the likes of Satya Nadella, Amanda K. Silver, Scott Guthrie, Sarah Bird, Charles Lamanna, Miti J., Kevin Scott, Asha Sharma, Rajesh Jha, Arun Ulag, Clay Wesener, and many more. And don't worry if you can't make it to Seattle, the event will be online and totally free to join. Click the image below to register for #MSBuild today! European Collab Summit - Germany - 14-16th May 2024 The clock is counting down to the amazing European Collaboration Summit, which takes place in Germany May 14-16, 2024. #CollabSummit2024 is designed to provide cutting-edge insights and best practices into Power Platform, Microsoft 365, Teams, Viva, and so much more. There's a whole host of experts speakers across the three-day event, including the likes of Vesa Juvonen, Laurie Pottmeyer, Dan Holme, Mark Kashman, Dona Sarkar, Gavin Barron, Emily Mancini, Martina Grom, Ahmad Najjar, Liz Sundet, Nikki Chapple, Sara Fennah, Seb Matthews, Tobias Martin, Zoe Wilson, Fabian Williams, and many more. Click the image below to find out more about #ECS2024 and register today! Microsoft 365 & Power Platform Conference - Seattle - 3-7th June If you're looking to turbo boost your Power Platform skills this year, why not take a look at everything TechCon365 has to offer at the Seattle Convention Center on June 3-7, 2024. This amazing 3-day conference (with 2 optional days of workshops) offers over 130 sessions across multiple tracks, alongside 25 workshops presented by Power Platform, Microsoft 365, Microsoft Teams, Viva, Azure, Copilot and AI experts. There's a great array of speakers, including the likes of Nirav Shah, Naomi Moneypenny, Jason Himmelstein, Heather Cook, Karuana Gatimu, Mark Kashman, Michelle Gilbert, Taiki Y., Kristi K., Nate Chamberlain, Julie Koesmarno, Daniel Glenn, Sarah Haase, Marc Windle, Amit Vasu, Joanne C Klein, Agnes Molnar, and many more. Click the image below for more #Techcon365 intel and register today! For more events, click the image below to visit the Microsoft Community Days website.
It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community. We're excited to announce that updating your community profile has never been easier! Keeping your profile up to date is essential for staying connected and engaged with the community. Check out the following Support Articles with these topics: Accessing Your Community ProfileRetrieving Your Profile URLUpdating Your Community Profile Time ZoneChanging Your Community Profile Picture (Avatar)Setting Your Date Display Preferences Click on your community link for more information: Power Apps, Power Automate, Power Pages, Copilot Studio Thank you for being an active part of our community. Your contributions make a difference! Best Regards, The Community Management Team
Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp
We're thrilled to announce that Ahmed Salih is our Super User of the Month for April 2024. Ahmed has been one of our most active Super Users this year--in fact, he kicked off the year in our Community with this great video reminder of why being a Super User has been so important to him! Ahmed is the Senior Power Platform Architect at Saint Jude's Children's Research Hospital in Memphis. He's been a Super User for two seasons and is also a Microsoft MVP! He's celebrating his 3rd year being active in the Community--and he's received more than 500 kudos while authoring nearly 300 solutions. Ahmed's contributions to the Super User in Training program has been invaluable, with his most recent session with SUIT highlighting an incredible amount of best practices and tips that have helped him achieve his success. Ahmed's infectious enthusiasm and boundless energy are a key reason why so many Community members appreciate how he brings his personality--and expertise--to every interaction. With all the solutions he provides, his willingness to help the Community learn more about Power Platform, and his sheer joy in life, we are pleased to celebrate Ahmed and all his contributions! You can find him in the Community and on LinkedIn. Congratulations, Ahmed--thank you for being a SUPER user!