HTTP authentication options in OF

Hi there,

I have been reading up on HTTP authentication possibilities in openframeworks. From what I can tell the ofxHTTP addon is the most suited, it’s really elaborate!

I’ve created an OSX app for which I want to add a free and also a ‘premium’ version. The premium version will be subscription based so I need to be able to authenticate the local user in some way (i.e. are they still subscribed). I have found https://auth0.com/ which seems to support exactly what I need. However, I am unsure on how to send a request to their servers, and with what protocol. I have looked at the twitter example (also described in thread below) but it is already outdated, and I’m not even sure if the used method is the one I need to be using.

Any pointer into the right direction? Auth0 supports all kinds of platforms, and would be free for a certain amount of ‘users’ and that is sufficient for me.

2 Likes

Hi there – when I go to the link above auto0.com I don’t get anything. Are you intended to use https://auth0.com/?

If you are trying to authorize a native app in OF, you might try an approach like this:

Essentially, all logging in happens online and the OF app only needs to get and post a bit of data.

There are get / post examples for ofxHTTP here

1 Like

woops, I didn’t intend to create a URL but I now fixed that.

I’ll start with this and keep you guys posted on progress! Thanks for the pointer and support so far.

Some time ago (like 3 years), I made some “similar testing” (users log and xml/JSON files management) using the Google Firebase. There were also a C++ API.
(@bakercp has some Google Cloud add-on too.)

There were a free testing account, and you needed to code some stuff using the JSON API.
I didn’t check this 0auth, maybe is simpler.

Cool @Maker_Bob if you post your progress on this!

Some progress here. I was successful with the POST example and was able to get a ‘token’ from the auth0 website for my ‘own’ API.

Based on the examples on their website I understand I can use this token to get e.g. user information (which is what my goal is). However, the GET example is quite cryptic for the level of knowledge that I have. Whereas the POST function uses data fields, which I can populate, the GET function needs me to add someting to the header:

curl --request GET
–url ‘https://dev-j3bnfzk6.eu.auth0.com/userinfo
–header ‘Authorization: Bearer {ACCESS_TOKEN}’
–header ‘Content-Type: application/json’

More specifically the access token. How can I do this? I tried the ‘addDefaultHeader’ in clientsessionsettings but I keep getting a 401 error as a response.

2 Likes

Hi!

hm… how is it possible to use ofxHTTP with a Bearer Token. Somebody has a hint? @bakercp do you have an example for that ?

greetings

ok, fiddled it out →

ofxHTTP::Context context;
ofxHTTP::ClientSessionSettings sessionSettings;
sessionSettings.addDefaultHeader(“Authorization”, “Bearer 66f…”);
context.setClientSessionSettings(sessionSettings);
response = client.execute(context, request);

1 Like

Interesting! I had a client who wanted Auth0 to work with an app I was developing for them, a few years ago, and I asked the Auth0 developers if they had a C/C++ API I could use, and they never got back to me, and the project faded away.

If it’s now possible to do, that’s great!