Skip to main content
Best answer

Session Auth: How response from main auth url can be used to call access_token in Test url call?


adilalich
Forum|alt.badge.img+1

Hi, I am creating a custom zapier integration. Authentication is Oauth 2.0 but grant_type = client_credentials. 

Article attached suggested I should use Session Auth in my case which is what I am doing.

ISSUE: My main Auth url is working fine. It returns a status code 200. I want to use the response returned, specifically access_token field from auth url response in the HTTP header of my Test API call. How can I use response from Auth url in Test API url?

HTTP Header should be like this: Authorization: Bearer your-access_token-goes-here
What I did: Authorization: Bearer {{bundle.authData.sessionkey}}

Best answer by adilalich

After doing some experiments I was able to figure it out on my own. 

Here’s what I did:

  • I created a computed field and gave it a key access_token (naming convention same as required by the API). 
  • Fetch the access_token (results.access_token) and stored it in a field access_token in Auth url section
  • used {{bundle.authData.access_token}} to use the access_token in the HTTP Header of Test API call.
View original
Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

4 replies

Wemakefuture
Forum|alt.badge.img+8
  • Zapier Expert
  • 166 replies
  • August 25, 2020

What did you sofar do? 

 

Did you use the get module? 

Did you use custom code? (Js/python)?


adilalich
Forum|alt.badge.img+1
  • Author
  • Zapier Expert
  • 25 replies
  • August 25, 2020

No, nothing out of the texbook. I am creating this integration through Platform UI. I am using JavaScript but I haven’t written any custom code. 


adilalich
Forum|alt.badge.img+1
  • Author
  • Zapier Expert
  • 25 replies
  • Answer
  • August 26, 2020

After doing some experiments I was able to figure it out on my own. 

Here’s what I did:

  • I created a computed field and gave it a key access_token (naming convention same as required by the API). 
  • Fetch the access_token (results.access_token) and stored it in a field access_token in Auth url section
  • used {{bundle.authData.access_token}} to use the access_token in the HTTP Header of Test API call.

Liz_Roberts
Forum|alt.badge.img+8
  • Zapier Staff
  • 1366 replies
  • August 26, 2020

Thanks for sharing the solution @adilalich !