Skip to content
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

Creating community users on a preview scratch org results in a JWT related error #1365

Closed
felixpelletier opened this issue Jan 17, 2022 · 10 comments
Labels
bug Issue or pull request that identifies or fixes a bug investigating We're actively investigating this issue

Comments

@felixpelletier
Copy link

Summary

Creating community users on a preview scratch results in a JWT related error.
The user is still created.
This seems to be related to the fact that the --instanceurl cannot be test.salesforce.com anymore in preview orgs, but must be a specific instance url.

Example:
This works:
sfdx auth:jwt:grant --clientid [CLIENT_ID] --jwtkeyfile [PATH_TO_KEYFILE] --username [COMMUNITY_USER] --instanceurl https://power-energy-7239-dev-ed.cs97.my.salesforce.com --setalias Test
This doesn't:
sfdx auth:jwt:grant --clientid [CLIENT_ID] --jwtkeyfile [PATH_TO_KEYFILE] --username [COMMUNITY_USER] --instanceurl test.salesforce.com --setalias Test

Steps To Reproduce:

Repository to reproduce: sfdx-preview-user-creation-bug

  1. sfdx force:org:create -f config\scratch-org-def.json -a user-creation-bug
  2. sfdx force:source:push -u user-creation-bug
  3. sfdx force:org:open -u user-creation-bug
  4. Go to the main admin user ("User User") and assign the "President" role.
  5. sfdx force:user:create --targetusername user-creation-bug --setalias BadUser --definitionfile config/user-def.json

Expected result

Successfully created user "[USERNAME]" with ID [USER_ID] for org [ORG_ID]

Actual result

ERROR running force:user:create: Error authenticating with JWT config due to: user hasn't approved this consumer
The user is still created, but hasn't logged in.

System Information

{
"cliVersion": "sfdx-cli/7.133.0",
"architecture": "win32-x64",
"nodeVersion": "node-v16.13.1",
"pluginVersions": [
"@oclif/plugin-autocomplete 0.3.0 (core)",
"@oclif/plugin-commands 1.3.0 (core)",
"@oclif/plugin-help 3.3.1 (core)",
"@oclif/plugin-not-found 1.2.6 (core)",
"@oclif/plugin-plugins 1.10.11 (core)",
"@oclif/plugin-update 1.5.0 (core)",
"@oclif/plugin-warn-if-update-available 1.7.3 (core)",
"@oclif/plugin-which 1.0.4 (core)",
"@salesforce/sfdx-plugin-lwc-test 0.1.7 (core)",
"alias 1.2.0 (core)",
"apex 0.7.0 (core)",
"auth 1.8.0 (core)",
"config 1.3.14 (core)",
"custom-metadata 1.0.12 (core)",
"data 0.6.8 (core)",
"generator 1.2.1 (core)",
"info 1.2.0 (core)",
"limits 1.3.0 (core)",
"org 1.11.0 (core)",
"salesforce-alm 53.7.2 (core)",
"schema 1.1.0 (core)",
"sfdx-cli 7.133.0 (core)",
"source 1.7.0 (core)",
"telemetry 1.4.0 (core)",
"templates 52.7.0 (core)",
"trust 1.1.0 (core)",
"user 1.7.0 (core)"
],
"osVersion": "Windows_NT 10.0.19042"
}

Additional information

@felixpelletier felixpelletier added the investigating We're actively investigating this issue label Jan 17, 2022
@github-actions
Copy link

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

@mshanemc mshanemc added the bug Issue or pull request that identifies or fixes a bug label Jan 27, 2022
@uip-robot-zz
Copy link

This issue has been linked to a new work item: W-10494033

@mshanemc
Copy link
Contributor

Yep, I can replicate this only on jwt, on v54.

Nice find, and thanks for reporting before the release!

@mshanemc
Copy link
Contributor

Notes: this might be fixable by using instance url ahead of loginUrl here
https://github.com/forcedotcom/sfdx-core/blob/7ed8b68561ec37148a01583d0188566913b17144/src/user.ts#L382

@mshanemc
Copy link
Contributor

@felixpelletier if you feel like mucking around in your node_modules and modifying that line of code and it solves your problem feel free to open a PR on that repo and ping me.

@felixpelletier
Copy link
Author

It does fix the problem of creating users, but I also get this error (regardless of whether I apply the fix or not):
ERROR running force:org:delete: Unable to associate this scratch org with a DevHub

I think this issue might be just a symptom of something else going on with preview scratch orgs, so I'm not sure if the fix would be appropriate here.

@mshanemc
Copy link
Contributor

@felixpelletier I got it working, too. But I didn't have the error with the scratch org delete that you saw (I have a gs0 dev hub)

@felixpelletier
Copy link
Author

felixpelletier commented Feb 2, 2022

W̶i̶t̶h̶ ̶t̶h̶e̶ ̶f̶i̶x̶ ̶a̶p̶p̶l̶i̶e̶d̶,̶ ̶w̶e̶'̶r̶e̶ ̶s̶t̶i̶l̶l̶ ̶h̶a̶v̶i̶n̶g̶ ̶i̶s̶s̶u̶e̶s̶.̶ ̶T̶h̶e̶ ̶c̶r̶e̶a̶t̶e̶d̶ ̶u̶s̶e̶r̶s̶ ̶a̶r̶e̶ ̶n̶o̶t̶ ̶i̶s̶ ̶t̶h̶e̶ ̶u̶s̶e̶r̶ ̶l̶i̶s̶t̶ ̶w̶h̶e̶n̶ ̶u̶s̶i̶n̶g̶ ̶f̶o̶r̶c̶e̶:̶u̶s̶e̶r̶:̶l̶i̶s̶t̶ ̶c̶o̶m̶m̶a̶n̶d̶ ̶o̶r̶ ̶t̶h̶e̶ ̶f̶o̶r̶c̶e̶:̶o̶r̶g̶:̶l̶i̶s̶t̶ ̶c̶o̶m̶m̶a̶n̶d̶.̶ ̶'̶s̶f̶d̶x̶ ̶f̶o̶r̶c̶e̶:̶u̶s̶e̶r̶:̶d̶i̶s̶p̶l̶a̶y̶ ̶-̶-̶t̶a̶r̶g̶e̶t̶u̶s̶e̶r̶n̶a̶m̶e̶ ̶[̶U̶S̶E̶R̶N̶A̶M̶E̶]̶ ̶-̶-̶j̶s̶o̶n̶'̶ ̶f̶a̶i̶l̶s̶ ̶w̶i̶t̶h̶ ̶t̶h̶e̶ ̶m̶e̶s̶s̶a̶g̶e̶:̶ ̶[̶T̶y̶p̶e̶E̶r̶r̶o̶r̶]̶ ̶C̶a̶n̶n̶o̶t̶ ̶r̶e̶a̶d̶ ̶p̶r̶o̶p̶e̶r̶t̶y̶ ̶'̶g̶e̶t̶F̶i̶e̶l̶d̶s̶'̶ ̶o̶f̶ ̶u̶n̶d̶e̶f̶i̶n̶e̶d̶"̶ ̶ ̶

I̶ ̶s̶t̶i̶l̶l̶ ̶t̶h̶i̶n̶k̶ ̶s̶o̶m̶e̶t̶h̶i̶n̶g̶ ̶e̶l̶s̶e̶ ̶i̶s̶ ̶b̶r̶o̶k̶e̶n̶ ̶h̶e̶r̶e̶.̶

@felixpelletier
Copy link
Author

EDIT: Nevermind me, I misunderstood my collegue. My appologies. The fix is indeed working fine. Thanks for your help!

@iowillhoit
Copy link
Contributor

This issue has been fixed and included in today's stable release 7.138.1. Update to the latest sfdx to get these changes. Release notes can be viewed here. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue or pull request that identifies or fixes a bug investigating We're actively investigating this issue
Projects
None yet
Development

No branches or pull requests

4 participants