hi all, i am trying to replicate this query https://developers.hubspot.com/docs/methods/oauth2/get-access-and-refresh-tokens
to POST in my app on appgyver
But not sure where I am going wrong ?
hi all, i am trying to replicate this query https://developers.hubspot.com/docs/methods/oauth2/get-access-and-refresh-tokens
to POST in my app on appgyver
But not sure where I am going wrong ?
For a proper OAuth flow, you need to first get your hands on the code
parameter by showing the user the login dialog. If you use the Open URL flow for that and then redirect back to the app with e.g. appgyverrn://auth?code=<code>
path, then use the App brought to foreground via URL type event for Receive event node, you’ll get access to the code.
Build service will let you configure custom URL schemes for your app in the future, so that this will work in a standalone build too: https://tracker.appgyver.com/feature-requests/p/allow-custom-url-schemes-to-be-configured-for-the-app-binaries-produced-by-build
As for the setup, first of all the Response key path field is meant to indicate the field under which the actual response is found, so if the API responded with { data: { foo: "bar"}}
, you’d set data
for the Response key path.
Then, you’d set each of the different key-value pairs as a schema for the POST request body, i.e. have grant_type
field whose value would then be authorization_code
.
However, the API requires the call to be made with body type application/x-www-form-urlencoded
which is not yet available for REST API direct integration data resources: https://tracker.appgyver.com/feature-requests/p/restful-data-resource-post-params-as-x-www-form-urlencoded
What I did now was enable the body type to be selected for the raw HTTP request node, so you can make the necessary API call with it – the downside is that the response will have no schema, but you can then wrap it in your own custom flow function to provide the schema:
The content of Request body is the formula
{grant_type: "authorization_code", client_id: "myId", client_secret: "mySecret", redirect_uri: "appgyverrn://auth", code: pageVars.code}
Note also that this approach causes the client secret to be saved in your app config, so someone viewing the app source code can see it in plaintext – typically, a custom backend would handle exchanging the code to the actual expiring tokens.
Thanks much @Harri_Sarsa I tried this but didnt get the output. Eventually i want to for eg: create a contact in my hubspot test crm account using a form on my appgyver account to capture some data. So i was trying to follow this guide https://developers.hubspot.com/docs/methods/contacts/create_contact
So how do i now run this api call to ensure it goes in successfully and creates the contact ?
i was trying to POST
using guides here https://developers.hubspot.com/docs/methods/contacts/create_contact
sill i get errors
Any news on this? I have the same issue since I’m trying to use a POST call with application/x-www-form-urlencoded but no success to use it
Thanks Harri
I’ve implemented your logic and I’ve been able to call a rest API in form-urlencoded
Many thanks for your work and for your professionality
@Munus and @Harri_Sarsa,
Please i need help in implemeting Firebase OAuth2 with AppGyver’s HTTP flow function. was following Harri’s example above but just couldn’t get my head around it especially the correct Redirect URI to use.
Thanks
Ciao lyn
Try to explain and give me more details
Maybe I can help u somehow
Hello @Munus,
I saw your comment about being able to implement OAuth2 using Harri’s Logic above.
Am working with Google’s Firebase and trying to BatchWrite documents to the Firestore database that requires the use of OAuth2 for authorization.
I tested it successfully with Postman but just doesn’t know how to replicate that using AppGyver. I then saw @Harri_Sarsa example above using the HTTP request flow function.
Can you please assist by showing how you did yours? I mean using OAuth2, how to get the authorization code and then using it to get the access Token. Also, how to open a second browser window for the user (me) to authenticate and authorize the request.
What’s the AppGyver URI to use in the HTTP Post request for the redirect call back from the Firebase authorization server.
Thanks