Giter Site home page Giter Site logo

Login via REST API about linkwarden HOT 5 OPEN

JGeek00 avatar JGeek00 commented on June 12, 2024
Login via REST API

from linkwarden.

Comments (5)

crkos avatar crkos commented on June 12, 2024

It is possible, This is basically what i had to do to make it work with Extension, You can take a look at my implementation in the extension in the actions and what calls that, or if you want to go and read the documentation of next-auth (or see what is called when you log in into Linkwarden) https://next-auth.js.org/getting-started/rest-api

https://github.com/linkwarden/browser-extension/blob/main/src/%40/lib/auth/auth.ts

from linkwarden.

habibur4340 avatar habibur4340 commented on June 12, 2024

For logging into your self-hosted Bitwarden through the REST API, if the documentation lacks specific details on authentication for existing users, consider looking into generic authentication endpoints often provided for session creation or token generation. Typically, APIs offer endpoints for "login" or "authenticate" actions, requiring credentials in the request body.

If further clarification or testing is needed, Apidog could be a valuable tool. It allows you to explore and test API endpoints interactively, helping you to understand the authentication flow, even when documentation is incomplete or unclear. Utilizing Apidog can assist in determining the correct approach for logging in via the API.

from linkwarden.

JGeek00 avatar JGeek00 commented on June 12, 2024

@crkos i have checked your implementation and I have done the same:

  1. Get the csrf token with the /auth/csrf endpoint
  2. Call to /auth/callback/credentials with the following form data, being callbackUrl "$baseUrl/login":
{
        "username": Uri.encodeFull(username),
        "password": Uri.encodeFull(password),
        "redirect": false,
        "csrfToken": Uri.encodeFull(csrfToken),
        "callbackUrl": Uri.encodeFull(callbackUrl),
        "json": true,
      }

But I receive a 302 from the second endpoint. Do you know why this can happen?

from linkwarden.

crkos avatar crkos commented on June 12, 2024

Mmm not really, did you send it as 'Content-Type': 'application/x-www-form-urlencoded'?, I think this is the only way to make it work, other thing is that you may already have a cookie set

from linkwarden.

JGeek00 avatar JGeek00 commented on June 12, 2024

Yes, I am adding the content type. I'm working on a Flutter mobile application but I cannot make to work the follow redirect after the response of that second endpoint. It appears that flutter's http package doesn't support follow redirect for post requests, so I'm getting a 302.

from linkwarden.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.