Skip to content

Commit 358b80d

Browse files
authoredMay 31, 2022
feat(providers): make issuer configurable on Salesforce (#4658)
1 parent 0a7a916 commit 358b80d

File tree

2 files changed

+32
-22
lines changed

2 files changed

+32
-22
lines changed
 

‎packages/next-auth/src/providers/salesforce.js

-22
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import type { OAuthConfig, OAuthUserConfig } from "."
2+
3+
export interface SalesforceProfile extends Record<string, any> {
4+
sub: string
5+
nickname: string
6+
email: string
7+
picture: string
8+
}
9+
10+
export default function Salesforce<P extends SalesforceProfile>(
11+
options: OAuthUserConfig<P>
12+
): OAuthConfig<P> {
13+
const { issuer = "https://login.salesforce.com" } = options
14+
return {
15+
id: "salesforce",
16+
name: "Salesforce",
17+
type: "oauth",
18+
authorization: `${issuer}/services/oauth2/authorize?display=page`,
19+
token: `${issuer}/services/oauth2/token`,
20+
userinfo: `${issuer}/services/oauth2/userinfo`,
21+
profile(profile) {
22+
return {
23+
id: profile.user_id,
24+
name: null,
25+
email: null,
26+
image: profile.picture,
27+
}
28+
},
29+
checks: ["none"],
30+
options,
31+
}
32+
}

1 commit comments

Comments
 (1)

mrcampbell commented on Jun 28, 2022

@mrcampbell

Not sure what happened, but all my apps using this code stopped working, throwing this error:

[next-auth][error][OAUTH_CALLBACK_ERROR] 
https://next-auth.js.org/errors#oauth_callback_error unexpected iss value, expected undefined, got: https://login.salesforce.com {
  error: {
    message: 'unexpected iss value, expected undefined, got: https://login.salesforce.com',
    stack: 'RPError: unexpected iss value, expected undefined, got: https://login.salesforce.com\n' +
      '    at Client.validateJWT (/Users/mikecampbell/shep-fly/core/node_modules/openid-client/lib/client.js:906:15)\n' +
      '    at Client.validateIdToken (/Users/mikecampbell/shep-fly/core/node_modules/openid-client/lib/client.js:741:60)\n' +
      '    at Client.callback (/Users/mikecampbell/shep-fly/core/node_modules/openid-client/lib/client.js:486:18)\n' +
      '    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n' +
      '    at async oAuthCallback (/Users/mikecampbell/shep-fly/core/node_modules/next-auth/core/lib/oauth/callback.js:112:16)\n' +
      '    at async Object.callback (/Users/mikecampbell/shep-fly/core/node_modules/next-auth/core/routes/callback.js:50:11)\n' +
      '    at async NextAuthHandler (/Users/mikecampbell/shep-fly/core/node_modules/next-auth/core/index.js:176:28)\n' +
      '    at async NextAuthNextHandler (/Users/mikecampbell/shep-fly/core/node_modules/next-auth/next/index.js:23:19)\n' +
      '    at async /Users/mikecampbell/shep-fly/core/node_modules/next-auth/next/index.js:59:32\n' +
      '    at async Object.apiResolver (/Users/mikecampbell/shep-fly/core/node_modules/next/dist/server/api-utils/node.js:185:9)',
    name: 'RPError'
  },
  providerId: 'salesforce',
  message: 'unexpected iss value, expected undefined, got: https://login.salesforce.com'
}
Please sign in to comment.