OAuth and API

  1. 3 months ago

    David S

    Mar 10 Pre-Release Testers, Xojo Pro
    Edited 3 months ago

    I am trying to understand the concept of using an API with OAuth using my Xojo Desktop app (2013 r3.3).

    I was reading about something similar here that uses OAuth with youtube but I am still confused about how the callback URI actually works.

    The API I am trying work work with requires authorization and then the results are all in JSON.

    I think the most confusing part is the OAuth authorization.

    Once I log in, I send a REQUEST and get a RESPONSE. I am pretty sure I can work through that part. It's the log in (and the callback URI) that confuses me.

    Found something that helps a lot here

    So I guess I just have to figure out how to read the callback string.

  2. Christoph D

    Mar 10 Pre-Release Testers, Xojo Pro
    Edited 3 months ago

    No need to re-invent the wheel. This is by far the best solution for OAuth: https://www.example-code.com/xojo/default.asp

  3. David S

    Mar 10 Pre-Release Testers, Xojo Pro

    So the redirect URI would actually be: http://localhost:3017/

  4. Dirk C

    Mar 13 Pre-Release Testers, Xojo Pro Belgium, Zedelgem

    @David S So the redirect URI would actually be: http://localhost:3017/

    Not necessarily, it could be myxojoapp://auth if you are on mobile
    Look at this page https://www.oauth.com/oauth2-servers/redirect-uris/
    Hopefully that will help somewhat.

  5. Thom M

    Mar 13 Pre-Release Testers Greater Hartford Area, CT

    Use an HTML viewer. Make the callback URI something you can predict, such as (as suggested) myxojoapp://auth and capture that in the HTMLviewer CancelLoad event. You can see a real-world example of this in https://github.com/thommcgrath/Beacon/blob/development/Project/Views/MiniBrowser.xojo_window - it has some Cocoa code you’ll need to work around a redirect detection issue on macOS.

  6. Edwin v

    Mar 13 Pre-Release Testers, Xojo Pro The Netherlands

    I try to get the oAuth 2 login to work as well.

    Using the Chilkat oAuth plugin for Xojo, the login actually works fine. But when I Log out, by removing the tokens, and want to login again I get an error saying that the port (or socket or something like that) is already in use. I am sure I have no instances of the previous oAuth session left.

    Anybody any experience with this kind of behavior?

  7. ronaldo f

    Mar 13 Philippines

    Hi Edwin,

    Are you using oAuth 2 login for xojo web app.?

  8. Edwin v

    Mar 13 Pre-Release Testers, Xojo Pro The Netherlands

    @ronaldoflorendo Are you using oAuth 2 login for xojo web app.?

    Hi Ronaldo, (Not the soccer player, right? ;) )

    No, I'm using it in a desktop project. But might use it for a web app in the future.
    There is actually a web app I use as a middleware app to do some operations on the user's behalf. The user will initialize the operation on the Desktop app. And since the tokens are "portable", I can use those on the middleware app to handle upload operations.

    But as far as login within a web app, no... not there yet.

  9. ronaldo f

    Mar 13 Philippines

    Thanks Edwin. We're both looking for oAuth 2 chilkat solution but mine is for web app. Good luck to us. :)

  10. Edwin v

    Mar 14 Pre-Release Testers, Xojo Pro The Netherlands

    @ronaldoflorendo Good luck to us. :)

    He! Thanks. I'm sure you might be able to work with the chilkat plugin. Maybe not in a way as described in the CK's examples. You just have to see if the target machine (where the app will be served at) is compatible.

or Sign Up to reply!