• Pynet

    (@pynet)


    Hello,
    We are a bit inexperienced with all this and are not quite sure how it works or if we have set it up wrong.
    We have followed the documentation and we think we are all set, however, we don’t know how to make the system take the variables (JWT, access data) for the autologin of the different users.
    Do we have to create a script?
    Does the plugin do it by itself?
    Are we missing something?
    Please give us some guidance.
    Thank you very much.
    Best regards

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author nicu_m

    (@nicu_m)

    Hello @pynet,

    In order to get the JWT, you can call the authentication endpoint with the user credentials.

    In order to autologin, you just need to generate a link like:

    https://your-site.com/?rest_route=/simple-jwt-login/v1/autologin&JWT=your-jwt-here

    If the JWT is valid, and not expired, you will be automatically redirected to the WordPress dashboard.

    Please let me know if this information was useful, or if you need any help.

    Best regards,

    Nicu.

    Thread Starter Pynet

    (@pynet)

    Hello,
    Thanks for getting back to us.
    We understand that part for now.
    Our goal is that when a user logs in, there will be a menu item that will allow him to connect to the second site in wordpress, but we don’t know how to specify the already encrypted JWT token, and the user credentials automatically and have wordpress display the final link.
    That is where we are getting stuck.
    Thanks.
    Best regards

    Plugin Author nicu_m

    (@nicu_m)

    In order to generate a JWt, you can use one of the suggested libraries from https://jwt.io/libraries.

    You just need to make sure when you generate the JWT, that you have in the payload the user email, or the user ID (based on the settings that you have set in WordPress settings) and that you sign the JWT with the same key.

    If you app is written in PHP, i would recommend using the firebase JWT library. Here you can see an example on how to generate a jwt: https://github.com/firebase/php-jwt#example-encodedecode-headers

    I will try to prepare a new blog post about this in the near future.

    Meanwhile, if you still haven’t managed to create the JWT, just tell me please in what programming language your app is written, and I will try to write a small demo for you.

    Thread Starter Pynet

    (@pynet)

    Hello,
    Thank you very much for all the information and links.
    We assume that, for what we need, it is necessary to use the hook “simple_jwt_login_login_hook”, to show the final link in the menu (to which we have put a title to be able to identify it and establish the link by code). Is it so?
    And yes, our main code is in PHP and although we have some of our own code in functions.php, we don’t have enough knowledge to do this process ourselves, so we’d appreciate all the help we can get here.
    For now, identifying yourself by email seems to be enough. We have set up both the JWT key and an Auth Codes key.
    Thank you very much!
    Best regards

    Thread Starter Pynet

    (@pynet)

    Hello,
    Any word on the code?
    Best regards

    Plugin Author nicu_m

    (@nicu_m)

    Hello,

    Sorry for my late reply. I just managed to write the first article in the documentation with code examples.

    You can check this link: https://simplejwtlogin.com/docs/code-examples/

    Please let me know if this helps.

    Best regards,

    Nicu.

    Thread Starter Pynet

    (@pynet)

    Hello,
    After taking a look at the tutorial (thank you very much for that), we still have a few little doubts about the operation and configuration.
    Our goal is to connect two websites. The user by clicking on a menu item on the main website (A) will be able to connect to the subdomain (B) directly. The registration of that user on B we will do manually for various reasons.
    That said:
    1- Does the plugin have to be installed and configured in the same way in both A and B?
    2- Is it possible to use a shortcode similar to the Mailpoet integration to display the link with the token on site A or is there another simpler way?
    3- The function shown in “Code examples” (once we have it adapted to our website) where should it go? In child-theme/functions.php?
    Thank you very much for all the help.
    Best regards

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Operational enquiry’ is closed to new replies.