API DATA SOURCE and Curl Requests

For users that want to know how to add basic authentication, the -u parameter in a Curl request.

In your browser open the console and type btoa('{{username}}:{{password}}'), replace {{username}} and {{password}} with the required credentials. It will return a base64 encoded string.

In the API Data Source just add an header, name Authorization and value Basic {{generated base64 string}}.

But please be aware that when using this in client-side script like with App Connect everyone can see you credentials. Never use it for credentials that the user may not access. You can use it for user credentials, when the user has to submit there own credentials.

Like @Freddy_Blockchain said but for @yarycling who isn’t alone, A Stripe-specific How-To would likely help a lot here for developers given the number of sites (wappler included :kissing_smiling_eyes:) using Stripe…

2 Likes

Oh yes! That howto for eg. stripe would also help to understand the concept of all other future API development! Highly required! Of course there are better solutions than stripe, just forgot the name :thinking:

Hey. No matter what i do i cant seem to submit:

<form is="dmx-api-form" id="apiform1" method="post" action="https://api.stripe.com/v1/charges" dmx-param:amount="100" dmx-param:currency="usd" dmx-header:authorization="Bearer sk_test_F6paz" dmx-param:source="tok" dmx-param:description="test" autosubmit="true"></form>

However if i use the define api schema once i pkugin data it works so i know the fields are correct.

Please note this a mobile development

Even in a mobile app it is possible for the user to retrieve the key out of your code. At least generate a Restricted key for your mobile app and don’t use your Secret key.

Doesn’t it submit the form? Do you see any network request if you inspect it in devtools of your browser.

1 Like

Code, Screenshot or working example with Stripe would be amazing!

I am afraid it is not possible to create tutorials for every API out there. That’s why the API providers usually have pretty good documentation on how to use their API.
We provide the tools to do this. As long as the issues are related to our tools, we can be of help but its up to you to check the API Docs.

I see that Authorization header is undefined and stripe doesn’t seem to respond. Can be a firewall or maybe Stripe blocks the request. Is there anything in the logs at the stripe dashboard?

You are right @Teodor but we could make a small section where each of us can publish the API instruction for the API we use.

If you notice sometime in the API reference people put help to use them in PHP Angular.js and other…
Every time one of us use an API can share in forum how it use it and more could write to the API developer to list instruction to use API in Wappler. In this case could be advertising for Wappler too

2 Likes

There are no transaction attempts in the dashboard. However, with the same config in the API schema, it works and I see the transaction in the dashboard.

@patrick - wappler uses stripe and so I’m guessing that wappler’s use of stripe implements wappler?
While while the wappler api might not handle such stripe requests out of the box, there must be a way? An encrypted key (to protect vars being passed to a server side script by anyone) is passed to a SSI script, which handles then the Stripe call via classic cURL means and gives the status in reply to wappler?

OK I see the problem you have.
You have to put the Stripe Authorization Bearer key within single quotes.

This is for all headers fields - if you don’t have dynamic values - always enclose them in single quotes.

image

So that should make it work :slight_smile:

Also I wonder why you use API Form as Forms are using for submitting data to the API and you are just fetching data so in that case API Data Source will do better.

1 Like

wonderful! Was also wondering about that. I’ll try out some APIs with these bearer tokens! Thanx so much.

1 Like

Well there you go:

1 Like

Yes yes that’s it. I am getting something now. Thanks much

I tried to connect to the API from Rossum.ai Invoice recognizionservice but not clear where to put autorization in wappler but get 404… via CURL , python no problem…

1 Like

Name : authorization
Value : ‘secret key’

tried it. still 405 method now allowed… confused now with api server side, client side and or api form/api action… I guess I need to use API Action and maybe thats why I get that 405 :thinking:

Header Name: Authorization
Header Value: secret_key poqMqDC...

I removed the first image of your post since it showed the whole secret key.