Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Postman #2272

Closed
DNoel26 opened this issue Jun 28, 2021 · 0 comments
Closed

Using Postman #2272

DNoel26 opened this issue Jun 28, 2021 · 0 comments
Labels
question Ask how to do something or how something works

Comments

@DNoel26
Copy link

DNoel26 commented Jun 28, 2021

I recently started learning NextAuth and I have three questions:

  1. Why does the session token only show in the browser and not Postman when I use the default signin and return a static user object?

  2. How do I setup Postman to work so that it doesn't skip the authorize function and callbacks?

  3. Why are my req and res objects undefined?

next-auth.session-token (only shows on browser)
next-auth.csrf-token (shows up on both browser and Postman)
next-auth.callback-url (shows up on both browser and Postman)

import NextAuth from 'next-auth';
import Providers from 'next-auth/providers';

const options = {
    session: {
        jwt: true,
        maxAge: 60 * 60,
    },
    callbacks: {
        async signIn(user, account, profile, req, res) {
            console.log('SIGNIN: ', user, account, profile, req, res);
            return true;
        },
        async redirect(url, baseUrl, req, res) {
            console.log('REDIRECT: ', url, baseUrl, req, res);
            return baseUrl;
        },
        async session(session, user, req, res) {
            console.log('SESSION: ', session, user, req, res);
            return session;
        },

        async jwt(token, user, account, profile, isNewUser, req, res) {
            console.log('JWT: ', token, account, req, res);
            return token;
        },
    },
    providers: [
        Providers.Credentials({
            credentials: {
                email: { label: 'email', type: 'email', placeholder: 'jdoe@email.com' },
                password: { label: 'password', type: 'password' },
            },

            async authorize(credentials, req) {
                **ENTERS HERE AND THEN CALLBACKS WHEN I SIGNIN ON LOCALHOST:PORT/API/AUTH/SIGNIN USING CHROME**
                **HOWEVER, DOES NOT ENTER HERE OR CALLBACKS USING POSTMAN**

                console.log('IN NEXT AUTH!!!');
                console.log(credentials, req);

               **REQ SHOWS UP AS UNDEFINED, SAME FOR REQ AND RES IN CALLBACKS**

                return {user: 'User'}
            },
        }),
    ],
};

export default (req, res) => NextAuth(req, res, options)

-- Please see the text in bold and caps above. Sorry if the issue is trivial but I don't know if I'm missing something...

@DNoel26 DNoel26 added the question Ask how to do something or how something works label Jun 28, 2021
@nextauthjs nextauthjs locked and limited conversation to collaborators Jun 28, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Ask how to do something or how something works
Projects
None yet
Development

No branches or pull requests

2 participants