-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
feat(providers): add NetSuite OAuth Provider #8865
feat(providers): add NetSuite OAuth Provider #8865
Conversation
Add NetSuite OAuth 2.0 Provider so users can use this integration with their NetSuite Account. Documentation has been added along with PNG of logo to render on Sign In. Additionally added to issue template.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
@HeavenlyEntity is attempting to deploy a commit to the authjs Team on Vercel. A member of the Team first needs to authorize it. |
fa96b45
to
65aa467
Compare
When will new providers be considered to be added? This one I do have working in a production environment. Let me know if there is anything I need to do on my side or how I can help you guys to speed up the process. 🚀 |
Hello @ThangHuuVu I see the new docs are looking great! Let me know how I can add the NetSuite doc instructions into the list of providers. Provide me with any new links to instructions on this would be great. Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we simplify / set as default any more of the configuration options?
In addition, a few things regarding the profile
optoin.
First, we'd like to always return at least the basic 4 profile fields without requiring the user to add their own callback. So the profile
option should look somethign like this:
profile(profile) {
return {
id: profile.id,
name: profile.full_name,
email: profile.email,
image: profile.avatar_url,
}
},
In addition, it looks like the token
argument to the callback isn't used in your example etiher, can we just drop that?
Finally, I see a lot of formatting / whitespace issues in the code at the bottom, and the JSDoc comment should follow the normal JSDoc formatting. See the src/providers/netlify.ts
(or any other provider) as an example 🙏
* | ||
* ::: | ||
*/ | ||
export default function NetSuite<P extends NetSuiteProfile>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other tiny tweak, if we name this options
, you can pull out whatever you need on like 213
, and then just pass the rest of the options
in under hte options
key on like 250
and don't need to pull out clientId
and clientSecret
additionally, for example.
i.e.
export default function NetSuite<P extends NetSuiteProfile>(
- config: OAuthNetSuiteOptions<P>
+ options: OAuthNetSuiteOptions<P>
): OAuthConfig<P> {
- const { issuer, userinfo: userInfo, prompt = 'none', scope = 'restlets rest_webservices', clientId, clientSecret } = config
+ const { issuer, userinfo: userInfo, prompt = 'none', scope = 'restlets rest_webservices', clientId, clientSecret } = options
return {
id: "netsuite",
name: "NetSuite",
type: "oauth",
checks: ["state"],
authorization: {
url: `https://${issuer}.app.netsuite.com/app/login/oauth2/authorize.nl`,
params: {
client_id: clientId,
prompt: prompt,
response_type: 'code',
scope,
}
},
token: {
url: `https://${issuer}.suitetalk.api.netsuite.com/services/rest/auth/oauth2/v1/token`,
params: {
grant_type: "authorization_code",
}
},
userinfo: userInfo,
profile(profile) {
// This is the default runtime.getCurrentUser() object returned from the RESTlet or SUITELet
return {
id: profile.id,
name: profile.name,
email: profile.email,
location: profile.location,
role: profile.role,
contact: profile?.contact
}
},
- clientId,
- clientSecret,
style: { logo: "/netsuite.png", bg: "#3a4f5f", text: "#fff" },
- options: config,
+ options
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is fine. You can commit this suggestion if you'd like. 👍🏼 @ndom91
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HeavenlyEntity I pushed that fix and cleaned up a few other small thigns 😊
Can you give it another test to make sure it still works? If it does we can merge it finally haha 🎉
Thanks for your patience with this! It'll be available in the next releases we cut (i.e. |
@HeavenlyEntity @ndom91 thanks for adding this provider! I have been trying to add NetSuite as a custom provider to my next.js app for a couple of days before I came across this PR. I have been unsuccessful and next-auth's errors aren't providing much help. But I wanted to ask how you determined the NetSuite documentation to follow to get this to work? I'm asking because I assumed I could go the route of NetSuite as OIDC provider, following this documentation: https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/chapter_160077062690.html The main difference in my approach was passing in the
Am i mistaken in my understanding of the purpose of the NetSuite as OIDC Provider approach, and should I be using your approach instead? As far as I can tell it seems like you are passing the authorization and token urls/params explicitly and using a custom RESTlet as the userinfo url. For the authorization params, scope is set to 'restlets rest_webservices', which also differs from the documentation that I followed which only lists 'openid' and 'email' as supported scopes. For reference here is my custom provider: {
id: 'netsuite',
name: 'NetSuite',
clientId: process.env.NS_CLIENT_ID,
clientSecret: process.env.NS_CLIENT_SECRET,
type: 'oauth',
wellKnown:
`https://${process.env.NS_ACCOUNT_ID}.suitetalk.api.netsuite.com/.well-known/openid-configuration`,
authorization: { params: { scope: 'openid email' } }, // by default only one of these is used, so i added params explicitly here
profile(profile) {
// I haven't gotten far enough to see what profile looks like yet
return profile;
},
}, |
Hi @mbaquerizo ! Yeah I have not had luck with the OIDC method because NetSuite is really strict with permissions and roles. You have to set up the permissions to allow users to auth this way. Which is extremely tedious. My approach utilizes OAuth 2.0 User Flow which NetSuite recommends. What is cool about this method the token returned from the |
@ndom91 Thank you for getting this in! I noticed the color is not right lol. Can you update that to be this color for the background #3a4f5f ➡️ #181a1b ? Then the text to #fbfbfb. Hope that can be committed directly. Thank you @ndom91! Wanna get it perfect before the release! 🚀 |
Co-authored-by: Nico Domino <yo@ndo.dev>
Add NetSuite OAuth 2.0 Provider so users can use this integration with their NetSuite Account. Documentation has been added along with PNG of logo to render on Sign In. Additionally added to issue template.
☕️ Reasoning
Add NetSuite OAuth provider for new and existing users looking to get started with integrating NetSuite using Auth.js! Lots of people and low documentation out there to help users create such compatibility. This will be the plug-n-play for those using NetSuite as there backend database provider / ERP System. 🎉 - Please let me know if I can make any adjustments!
🧢 Checklist
🎫 Affected issues
None ✅
📌 Resources