OAuth 1 & 2 on AdonisJS & JWT Tokens



I use AdonisJS, VueJS, NuxtJS, and JWT tokens for authentication.

My need :

I would like each user to connect his Twitter account and his Facebook account to his personal account via AdonisJS once logged in only. This is not a login button.

For that, it would be necessary to use a packet OAuth 1 & 2.

What are you purpose?
Thank you.



I have this exact process in my application.

Ally social auth can help with this.

After you authenticate the user’s JWT with your application you can then use Ally to authenticate with social app to retrieve and save access tokens or other data.

A contrived example:

  async connectFacebookCallback ({ ally, auth, response }) {
    let user = auth.user // from JWT
    let facebookUser = await ally.driver('facebook').getUser()

    user.fb_access_token = facebookUser.accessToken
    await user.save()


The problem is that it is not an XHR injection with the JWT & Bearer token. This is a simple http redirection to a page that calls the URL redirection to the Twitter connection.

async redirect ({ally}) {
  await ally.driver(this.network).redirect()

async callback ({ally, auth, response, params}) {
  try {
    const user = await auth.getUser()
    const credentials = await ally.driver(this.network).getUser()

  } catch (e) {