• Resolved Greg

    (@rebootnow)


    Justin, thanks for this plugin.

    Is there support for adding an endpoint that isn’t below /oauth/ ?

    I see that I can add one below /oath/ using the ‘wo_endpoints’ filter, but I need endpoints on a different path, say /custom/api/{method}.

    I have read the docs and taken a quick look at the code, but I can’t see an obvious answer. Am I missing something?

    https://wordpress.org/plugins/oauth2-provider/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Justin Greer

    (@justingreerbbi)

    Hi @greg,

    Currently there is no way to add an endpoint to WP OAuth Server that is below the “oauth” URI. This is something that you are going to have to do in either a custom plugin that hooks into WP OAuth Server it in your functions.php theme file.

    You can refer to WP OAuth Server main file as to how you can create your own custom endpoints. You should have no issue tapping into WP OAuth Server after that.

    Thread Starter Greg

    (@rebootnow)

    Thanks Justin. Actually, I’m trying to add an endpoint that is NOT below the oath URI.

    I was assuming a custom plugin of some sort, but I guess a more precise framing of my question would be whether it is possible to add a custom endpoint at /something/api/{method} …

    1. with a filter, OR
    2. will I have to extend the WO_Server class

    I think you’re saying it is #2.

    BTW, thanks for such a rapid response to my original question.

    Plugin Author Justin Greer

    (@justingreerbbi)

    You can create your own plugin and make your own custom endpoint from there. Then you can hook into WP OAuth Server’s core to do what you need to do in regards to retrieving/validating tokens.

    I do not advocate that you edit WP OAuth Server directly as that will result in your changes being wiped out on any update of the plugin.

    Thread Starter Greg

    (@rebootnow)

    By “extend” I meant derive a new class with WO_Server as the parent. I wouldn’t edit your plugin code directly.

    > hook into WP OAuth Server’s core to do what you need to do in regards to
    > retrieving/validating tokens

    Yes, this is what I’m trying to figure out. 🙂

    Plugin Author Justin Greer

    (@justingreerbbi)

    Extending WP OAuth Server is done by using WordPress actions and filters. You can find more about WordPress actions and filters at https://codex.wordpress.org/Plugin_API/Hooks.

    You can also find some more information on specific actions by browsing the cope for WP OAuth Server. We are currently making documentation tailored to specific tasks such as extending the API.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding a new endpoint (arbitrary URL)’ is closed to new replies.