function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jugbeer BholaJugbeer Bhola 

Authorize Salesforce Org From VSCode

Cannot authorize my newly refreshed Sandbox Org from VSCode to Salesforce.  

Receive an error of: Cannot read properties of undefined (reading 'id')

This occurred after my Sandbox was recently refreshed from Production.  I can authorize other Sandboxes from VSCode without a problem.  This is an Org specific issue.  


The suggestions on the web were not helpful.  Sfdc update and CLI update did not change anything. 

I did notice that HTTP method logged within Salesforce appears as Unknown.  


User-added imageUser-added image
Is there somewhere in VSCode that I can specifiy the HTTP method or does someone have another solution?

Best Answer chosen by Jugbeer Bhola
Jugbeer BholaJugbeer Bhola
The URL to connect to the Sandbox used to be:

https://member-access-wi--jbhola.my.salesforce.com

After the refresh it became:

https://member-access-wi--jbhola.sandbox.my.salesforce.com

This is related to 'Enhanced Domains' Salesforce is pushing out.

All Answers

SwethaSwetha (Salesforce Developers) 
HI Jugbeer ,
Can you run the authorize command using the --dev-debug switch and see if you find any differences between working and non working orgs.

For example: sfdx force:org:create -f config/project-scratch-def.json -a sourcescratchorg --dev-debug

Similar: https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000BrAN8SAN

If this information helps, please mark the answer as best. Thank you
Jugbeer BholaJugbeer Bhola

The switch of --dev-debug did not offer me insight. Just showed me the same error.  The terminal output is below. 

The link you sent me to looks like the same topic but it does not look like it was solved there either.

If you can see something please let me know.

Thanks.

  sf:WebOAuthServer DEBUG OAuth web login service listening on port: 1717 +0ms
  sf:WebOAuthServer DEBUG Starting web auth flow +2ms
  sf:WebServer DEBUG socket connection initialized from 127.0.0.1 +34s
  sf:WebOAuthServer DEBUG processing request for uri: /OauthRedirect +34s
  sf:WebOAuthServer DEBUG request.query.state: 527c0969edf7 +1ms
  sf:WebOAuthServer DEBUG Successfully obtained auth code: ...HkQ== +4ms
  sf:WebOAuthServer DEBUG oauthConfig.loginUrl: https://member-access-wi--sjbhola.my.salesforce.com/ +2ms
  sf:WebOAuthServer DEBUG oauthConfig.clientId: PlatformCLI +1ms
  sf:WebOAuthServer DEBUG oauthConfig.redirectUri: http://localhost:1717/OauthRedirect +0ms
  sf:core TRACE Setup child 'OrgAccessor' logger instance +34s
  sf:core TRACE Setup child 'SandboxAccessor' logger instance +2ms
  sf:core TRACE Setup child 'AliasesConfig' logger instance +1ms
  sf:AliasesConfig INFO Reading config file: C:\Users\jbhola\.sfdx\alias.json +0ms
  sf:WebServer DEBUG socket connection initialized from 127.0.0.1 +22ms
  sf:core TRACE Setup child 'TokensConfig' logger instance +8ms
  sf:core TRACE Setup child 'crypto' logger instance +2ms
  sf:crypto DEBUG retryStatus: undefined +0ms
  sf:core TRACE Setup child 'keyChain' logger instance +1ms
  sf:keyChain DEBUG platform: win32 +0ms
  sf:TokensConfig INFO Reading config file: C:\Users\jbhola\.sfdx\tokens.json +0ms
  sf:core TRACE Setup child 'AuthInfo' logger instance +7ms
  sf:AuthInfo INFO Exchanging auth code for access token using loginUrl: https://member-access-wi--sjbhola.my.salesforce.com/ +0ms
  sf:WebServer DEBUG socket connection initialized from 127.0.0.1 +225ms
  sf:core TRACE Setup child 'auth' logger instance +534ms
  sf:auth DEBUG  +0ms
  sf:WebOAuthServer DEBUG closing server connection +559ms
ERROR running auth:web:login:  Cannot read properties of undefined (reading 'id') 
*** Internal Diagnostic ***

Type: Cannot read properties of undefined (reading 'id')
    at Function.wrap (C:\Users\jbhola\AppData\Local\sfdx\client\7.158.1-fab005f\node_modules\@salesforce\core\lib\sfError.js:61:25)
    at Login.catch (C:\Users\jbhola\AppData\Local\sfdx\client\7.158.1-fab005f\node_modules\@salesforce\command\lib\sfdxCommand.js:267:38)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Login._run (C:\Users\jbhola\AppData\Local\sfdx\client\7.158.1-fab005f\node_modules\@salesforce\command\lib\sfdxCommand.js:93:13)
    at async Config.runCommand (C:\Users\jbhola\AppData\Local\sfdx\client\7.158.1-fab005f\node_modules\@oclif\config\lib\config.js:173:24)
    at async SfdxMain.run (C:\Users\jbhola\AppData\Local\sfdx\client\7.158.1-fab005f\node_modules\@oclif\command\lib\main.js:27:9)
    at async SfdxMain._run (C:\Users\jbhola\AppData\Local\sfdx\client\7.158.1-fab005f\node_modules\@oclif\command\lib\command.js:43:20)
    at async Object.run (C:\Users\jbhola\AppData\Local\sfdx\client\7.158.1-fab005f\dist\cli.js:162:47)
******

  sf:Login ERROR [
  sf:Login   '\x1B[1mERROR running auth:web:login: \x1B[22m',
  sf:Login   "\x1B[31mCannot read properties of undefined (reading 'id')\x1B[39m",
  sf:Login   '\x1B[31m\x1B[39m\n' +
  sf:Login     '\x1B[31m*** Internal Diagnostic ***\x1B[39m\n' +
  sf:Login     '\x1B[31m\x1B[39m\n' +
  sf:Login     "\x1B[31mType: Cannot read properties of undefined (reading 'id')\x1B[39m\n" +
  sf:Login     '\x1B[31m    at Function.wrap (C:\\Users\\jbhola\\AppData\\Local\\sfdx\\client\\7.158.1-fab005f\\node_modules\\@salesforce\\core\\lib\\sfError.js:61:25)\x1B[39m\n' +
  sf:Login     '\x1B[31m    at Login.catch (C:\\Users\\jbhola\\AppData\\Local\\sfdx\\client\\7.158.1-fab005f\\node_modules\\@salesforce\\command\\lib\\sfdxCommand.js:267:38)\x1B[39m\n' +
  sf:Login     '\x1B[31m    at processTicksAndRejections (node:internal/process/task_queues:96:5)\x1B[39m\n' +
  sf:Login     '\x1B[31m    at async Login._run (C:\\Users\\jbhola\\AppData\\Local\\sfdx\\client\\7.158.1-fab005f\\node_modules\\@salesforce\\command\\lib\\sfdxCommand.js:93:13)\x1B[39m\n' +        
  sf:Login     '\x1B[31m    at async Config.runCommand (C:\\Users\\jbhola\\AppData\\Local\\sfdx\\client\\7.158.1-fab005f\\node_modules\\@oclif\\config\\lib\\config.js:173:24)\x1B[39m\n' +
  sf:Login     '\x1B[31m    at async SfdxMain.run (C:\\Users\\jbhola\\AppData\\Local\\sfdx\\client\\7.158.1-fab005f\\node_modules\\@oclif\\command\\lib\\main.js:27:9)\x1B[39m\n' +
  sf:Login     '\x1B[31m    at async SfdxMain._run (C:\\Users\\jbhola\\AppData\\Local\\sfdx\\client\\7.158.1-fab005f\\node_modules\\@oclif\\command\\lib\\command.js:43:20)\x1B[39m\n' +
  sf:Login     '\x1B[31m    at async Object.run (C:\\Users\\jbhola\\AppData\\Local\\sfdx\\client\\7.158.1-fab005f\\dist\\cli.js:162:47)\x1B[39m\n' +
  sf:Login     '\x1B[31m******\x1B[39m\n' +
  sf:Login     '\x1B[31m\x1B[39m'
  sf:Login ] +35s
  @oclif/config start postrun hook +35s
  @oclif/config postrun hook done +3ms
  sf:WebServer DEBUG number of connections open: 0 +392ms
  lazy-require saving type cache to C:\Users\jbhola\AppData\Local\sfdx\module-types.json +36s
  lazy-require no changes to save +1ms
  sfdx:telemetry@2.0.0 Spawning "C:\Users\jbhola\AppData\Local\sfdx\client\7.158.1-fab005f\bin\node.exe C:\Users\jbhola\AppData\Local\sfdx\client\7.158.1-fab005f\node_modules\@salesforce\plugin-telemetry\processes\upload C:\Users\jbhola\AppData\Local\sfdx C:\Users\jbhola\AppData\Local\Temp\sfdx-telemetry\telemetry-a8b64796f1298ecb4b76d8c5633e11d100a142d3.log" +35s
PS C:\__BigComp_DevAmp\accessmain> 

Jugbeer BholaJugbeer Bhola
The URL to connect to the Sandbox used to be:

https://member-access-wi--jbhola.my.salesforce.com

After the refresh it became:

https://member-access-wi--jbhola.sandbox.my.salesforce.com

This is related to 'Enhanced Domains' Salesforce is pushing out.
This was selected as the best answer