Secure Your WordPress REST API with JWT Authentication: A Step-by-Step Guide | WordPress | E2

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 66

  • @BuntyWP
    @BuntyWP  Год назад +2

    Thanks for watching! Don't forget to subscribe and follow me on Twitter and Instagram. Links are in the description.

  • @rotondwachris2382
    @rotondwachris2382 7 месяцев назад +1

    hi how to put attention on get request?

    • @rotondwachris2382
      @rotondwachris2382 7 месяцев назад +1

      *Authentication

    • @BuntyWP
      @BuntyWP  7 месяцев назад

      Check out this video ruclips.net/video/wIk4k5dytcg/видео.html

  • @codingtostopprocrastinatio9748
    @codingtostopprocrastinatio9748 7 месяцев назад +1

    Really useful info. Maybe you can create a Gutenberg swiper slider block tutorial (or slick.js ) ?

    • @BuntyWP
      @BuntyWP  7 месяцев назад

      Thank you for the suggestion. I will try this. Currently I am also in a learning curve of building blocks.

    • @codingtostopprocrastinatio9748
      @codingtostopprocrastinatio9748 7 месяцев назад

      @@BuntyWP Same here. It is very different and somewhat harder than doing it with ACF. Need to study React JS alongside.

    • @BuntyWP
      @BuntyWP  7 месяцев назад

      @@codingtostopprocrastinatio9748 According to me making blocks with ACF is very simple. We don't need react for that. I've already made tutorial on that.

  • @stefanwillebrand4202
    @stefanwillebrand4202 11 месяцев назад +1

    It worked well for me to generate the token but when I try to create a post or just request the validate endpoint I get the following error, any thoughts?
    {
    "code": "jwt_auth_bad_config",
    "message": "JWT is not configured properly, please contact the admin",
    "data": {
    "status": 403
    }
    }

    • @BuntyWP
      @BuntyWP  11 месяцев назад

      I hope you are creatng post with user who has access to create post.
      Also make sure you define the JWT_AUTH_SECRET_KEY in the wp-config.php
      Sometimes you have to enable CORS. Try defining JWT_AUTH_CORS_ENABLE in the wp-config

  • @yassinebenlahbib1058
    @yassinebenlahbib1058 Год назад +1

    THANK YOU SO MUCH BRO YOU'RE A LIFE SAVER!

    • @BuntyWP
      @BuntyWP  Год назад

      Thank you for your kind words. Hope this was helpful.

  • @mistertgmistertg
    @mistertgmistertg Год назад

    It is such a clear tutorial on this specific topic. Thanks !

    • @BuntyWP
      @BuntyWP  Год назад

      I am glad to know that this was helpful to you.

  • @kidtnt3824
    @kidtnt3824 Год назад +1

    Good video thanks! Do you know if cookie authentication works for remote apps, or do we have to have other authentication methods (like JWT) for a remote app to connect to WP API? Basically I have a react app for which I want the users who are logged in to the WP site (and thus have a WP logged in cookie set), to be able to make calls to this WP API from our react app.

    • @BuntyWP
      @BuntyWP  Год назад

      Coockie authentication is available, but I think we can't use for Apps. It's better to use this JWT Or Auth for your React app.
      You can read the article at here about authentication developer.wordpress.org/rest-api/using-the-rest-api/authentication/#authentication-plugins

  • @GaganVerma-m9m
    @GaganVerma-m9m Год назад

    Superb buddy, You cleared my way to go ahead. Let me buy a beer for you 😀

    • @BuntyWP
      @BuntyWP  Год назад +1

      Thanks for your kind words. I am glad this is helpful to you.

  • @ravindu2movie
    @ravindu2movie Год назад

    Really help to me. Thanks a lot.

    • @BuntyWP
      @BuntyWP  Год назад +1

      Thank you for your kind words

  • @Samuellucas243
    @Samuellucas243 Год назад +1

    salvou minha vida man obg!

    • @BuntyWP
      @BuntyWP  Год назад

      Obrigado. Espero que tenha sido útil

  • @davidofug
    @davidofug Год назад

    This is brilliant.
    Are you planning to publish a tutorial that shows how to make orders via API on a WooCommerce-powered WordPress website?
    Am

    • @BuntyWP
      @BuntyWP  Год назад

      Currently, there is no such plan.

  • @codingtostopprocrastinatio9748

    Can we do it without an additional plugin for authentication ?

    • @BuntyWP
      @BuntyWP  Год назад

      You mean JWT token without plugin? OR different type of authentication?
      We can do anything, but it will require a custom code.

    • @codingtostopprocrastinatio9748
      @codingtostopprocrastinatio9748 7 месяцев назад

      @@BuntyWP Yes, i meant without the plugin. Ty for answer.

  • @breaktech1834
    @breaktech1834 Год назад

    hello brother
    it's great information video.
    but,
    Wocommerace no data Get ma Error ave che. please can you help me?

    • @BuntyWP
      @BuntyWP  Год назад

      It would be great if you provide more details like which API you are trying? What error you are getting?

  • @AlexandreSoete
    @AlexandreSoete 4 месяца назад

    Thx men ! it's perfect :)

    • @BuntyWP
      @BuntyWP  4 месяца назад

      Most welcome. Hope you have subscribed the channel ;)

    • @AlexandreSoete
      @AlexandreSoete 4 месяца назад

      @@BuntyWP Now yes haha !

    • @BuntyWP
      @BuntyWP  4 месяца назад

      @@AlexandreSoete Thanks buddy

  • @srai2154
    @srai2154 3 месяца назад

    I followed the same process but was not able to create a post via api

    • @BuntyWP
      @BuntyWP  3 месяца назад

      What are you getting in the response?

  • @wotwot2
    @wotwot2 Год назад

    This plugin has not been updated in 8 months? Kind of worried to use this plugin for a large project

    • @BuntyWP
      @BuntyWP  Год назад +1

      Well, if it is not updated, doesn't mean it is vulnerable. But you can anyways contact the plugin author.

    • @wotwot2
      @wotwot2 Год назад

      @@BuntyWP Is it still working well for you?

    • @BuntyWP
      @BuntyWP  Год назад +1

      @@wotwot2 Yes. Are you having any trouble using this?

    • @wotwot2
      @wotwot2 Год назад

      @@BuntyWP I have not yet tried, I was just a bit worried that it may have been breaking sites due to compatibility issues because of lack of updates. If it is still working well for you, I will give it a shot :)

    • @BuntyWP
      @BuntyWP  Год назад

      @@wotwot2 Yep, just try it.

  • @sohanwagh5447
    @sohanwagh5447 7 месяцев назад

    i followed all steps but token is not generating . when i paste the link i get 404 error

    • @BuntyWP
      @BuntyWP  7 месяцев назад

      Make sure you set the permalink. from the backend.
      id yoursiteurl/wp-json showing 404 too?

  • @anirudhachakrabarty2050
    @anirudhachakrabarty2050 Год назад

    I tried generating the jwt auth token via postman but it is giving error -
    {
    "code": "rest_no_route",
    "message": "No route was found matching the URL and request method.",
    "data": {
    "status": 404
    }
    }

    • @BuntyWP
      @BuntyWP  Год назад

      Make sure you do correct URL, JWT plugin active, add constant in wp-config and your permalink is set.

    • @srai2154
      @srai2154 3 месяца назад

      @@BuntyWP I followed the all above process but still not able to create a post via api

    • @thangaraj120com
      @thangaraj120com 3 месяца назад

      @@srai2154 @buntyWP I too having this same issue

    • @BuntyWP
      @BuntyWP  3 месяца назад

      Make sure to save permalinks

    • @thangaraj120com
      @thangaraj120com 3 месяца назад

      @@BuntyWP No luck :( Still there is the same issue

  • @tochukwuokafor1251
    @tochukwuokafor1251 Год назад

    Good day pls how can i authenticate an an api by verifying the current user is logged in without the use of plugins. Pls I need your help, anybody with such will also be appreciated

    • @BuntyWP
      @BuntyWP  Год назад

      May be coockie auth might helpful developer.wordpress.org/rest-api/using-the-rest-api/authentication/#cookie-authentication
      But most recommended way is to authentication.
      WP's official document recommends that developer.wordpress.org/rest-api/using-the-rest-api/authentication/#authentication-plugins

    • @tochukwuokafor1251
      @tochukwuokafor1251 Год назад

      @@BuntyWP pls sir I don't know how to go about it pls🙏🙏 can you register rest api endpoint that has callback to get current user and a permission callback to check if the user is lodged in. I really appreciate it if you show the code on how to embark on such task

    • @BuntyWP
      @BuntyWP  Год назад

      @@tochukwuokafor1251 For that you hve to use any authentication only. WP has no such API which does that.
      So from Authentication plugin, you will get a token as shown in this video. Token is an identifier of that user, by which WP determines which user is that.
      One token is generated, you can use permission callback like shown here ruclips.net/video/id1FFLZT5oE/видео.html
      I would suggest you to go through my WP REST API playlist, your concept will be clear about this.
      I've added Playlist URL in the description.

    • @tochukwuokafor1251
      @tochukwuokafor1251 Год назад

      @@BuntyWP okay I can see that you can pass a bearer token to check if user is logged in from the post man. Now my question is there a way to pass the bearer token into the wp rest api URL (may be in the headers or URL query params) for someone to consume on the frontend(react)

    • @BuntyWP
      @BuntyWP  Год назад

      @@tochukwuokafor1251 Yes, you can pass it to header like this prnt.sc/ly0Fm1oAFrem
      I am not sure how to pass header in react, but I hope you get the idea. Let me know if that helps