static-web-apps-cli icon indicating copy to clipboard operation
static-web-apps-cli copied to clipboard

Cannot login or deploy application: findCredentials is not a function error

Open brt0555 opened this issue 1 year ago • 10 comments

Before filing this issue, please ensure you're using the latest CLI by running swa --version and comparing to the latest version on npm.

Are you accessing the CLI from the default port :4280 ?

  • [ ] No, I am using a different port number (--port) and accessing the CLI from that port
  • [X ] Yes, I am accessing the CLI from port :4280

Make sure you are accessing the URL printed in the console when running swa start!

ℹ️ NOTE: Make sure to enable debug logs when running any swa commands using --verbose=silly

Describe the bug I cannot deploy an application. It was working fine, but I have updated to the newest version. During running swa deploy i got:

Checking Azure session... Executing authenticateWithAzureIdentity

  • details:
    • tenantId:
    • clientId:
    • clientSecret:
  • useKeychain: true Keychain is enabled Executing swaCliPersistencePlugin Executing before cache access plugin Machine ID: Invoking crypto service Getting credentials Getting credentials from native keychain Getting keychain reference isKeychainEnabled: true KeychainCache: undefined Attempting to load native keychain Executing after cache access plugin Machine ID: Invoking crypto service Did TokenCacheContext cache changed: true Setting credentials in keychain Encrypting credentials Encrypted credentials: Setting credentials in native keychain Getting keychain reference isKeychainEnabled: true KeychainCache: undefined Attempting to load native keychain ✖ Failed to setup project: this.keychainCache.findCredentials is not a function

✖ If you believe this behavior is unexpected, please raise a GitHub issue at: https://github.com/Azure/static-web-apps-cli/issues/new/choose It also happens when i try toswa login`

Configuration used: { "$schema": "https://aka.ms/azure/static-web-apps-cli/schema", "configurations": { "app-frontend": { "appLocation": ".", "outputLocation": "dist", "appBuildCommand": "npm run build", "run": "npm run dev", "appDevserverUrl": "http://localhost:5173", "tenant": "XXXX", "appName": "app-stage", "resourceGroup": "app-sgr-stage", "env": "prod" } } }

Desktop (please complete the following information):

  • OS: Windows
  • Version 11

brt0555 avatar Aug 21 '24 09:08 brt0555

I am having the same issue after updating to version 2.0.1 and am unable to deploy.

laurieatkinson avatar Aug 22 '24 16:08 laurieatkinson

Hi, acknowledging this issue. We will test this locally and get it resolved. In the meantime, are you able to login or deploy using a prior version?

Timothyw0 avatar Aug 29 '24 18:08 Timothyw0

+1 facing the same issue. OS: macOS 14.6.1 (23G93) Processor: Apple M3 Pro SWA Version: 2.0.1

kirtimaan-askin avatar Sep 02 '24 05:09 kirtimaan-askin

Solution: https://github.com/Azure/static-web-apps-cli/issues/879#issuecomment-2283416213

Login first with az login, then swa login.

rodrigorodriguez avatar Sep 04 '24 16:09 rodrigorodriguez

Going to give it a try and update back

From: Rodrigo Rodriguez @.> Date: Wednesday, 4 September 2024 at 21:54 To: Azure/static-web-apps-cli @.> Cc: Kirtimaan Lodha @.>, Comment @.> Subject: Re: [Azure/static-web-apps-cli] Cannot login or deploy application: findCredentials is not a function error (Issue #885)

Solution: #879 (comment)https://github.com/Azure/static-web-apps-cli/issues/879#issuecomment-2283416213

Login first with az login, then swa login.

— Reply to this email directly, view it on GitHubhttps://github.com/Azure/static-web-apps-cli/issues/885#issuecomment-2329502128, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A5VOFDDZHOO2CNH5X2B3SZDZU4X4DAVCNFSM6AAAAABM3TB3OCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRZGUYDEMJSHA. You are receiving this because you commented.Message ID: @.***>

kirtimaan-askin avatar Sep 05 '24 08:09 kirtimaan-askin

I can confirm that installing Azure CLI on my MacBook and then using az login to same tenant and subscription solved the issue. After az login, I am able to deploy the SWA from latest stable release of the swa package. Thank @rodrigorodriguez

Definitely this can be marked and documented as a setup step or a dependency though

kirtimaan-askin avatar Sep 07 '24 05:09 kirtimaan-askin

+1 for issue. Affects the Visual Studio publish as it seems to shell to swa.cmd.

malthuswaswrong avatar Sep 10 '24 21:09 malthuswaswrong

@malthuswaswrong you can try using az cli to login first, and then try VS publish

kirtimaan-askin avatar Sep 12 '24 10:09 kirtimaan-askin

I’m still getting the same error even after running az login. Image

sergiojrdotnet avatar Nov 24 '24 17:11 sergiojrdotnet

This error continues to haunt me well into 2025. Some things to try:

Make sure you're logged into the Azure CLI:

az login --scope https://management.azure.com//.default

Then login to SWA while skipping the keychain:

swa login --clear-credentials --no-use-keychain

As a last resort, fetch the deploy token:

az staticwebapp secrets list --name "<your_app_name>" --query "properties.apiKey" -o tsv

Add it to your environment:

# powershell
$env:SWA_CLI_DEPLOYMENT_TOKEN = "<your_token>"
# bash
export SWA_CLI_DEPLOYMENT_TOKEN="<your_token>"

And try your deploy again; ie:

npx swa build && npx swa deploy --env production

phuze avatar Aug 13 '25 19:08 phuze