# Troubleshooting Credentials

If you are having issues with the credential store, please verify a couple of things. More than likely, it's one of the following issues:

### Pathing

Verify that you are not setting the <mark style="color:blue;">**`current working directory`**</mark> to something outside of the executable while the Perigee is initializing.&#x20;

A typical load cycle for a Perigee Application looks like this:

```csharp
//Initialize Perigee, and configure credentials
PerigeeApplication.ApplicationNoInit("App", (c) => {

   CredentialStore.RegisterConnectionString("main", "main_test");
   CredentialStore.RegisterRefresh("customCred", (o) => {});
   
});
```

This verifies that the current working directory and pathing is correct. This will load the credential file under `$WorkingDirectory/credentialStore/credentials.[pcb|pce]` depending on the encryption settings.

#### Initialize outside Perigee

See the documentation in [PerigeeApplication](/core-modules/perigeeapplication.md).&#x20;

### Naming the Credential

Unless you've got a VERY specific reason to do so, please don't name the credential. The reason is that you want the **`RefreshName`** to match the **`CredentialName`**.&#x20;

In the below <mark style="color:red;">**BAD**</mark> example, we're naming it <mark style="color:red;">`"DiffName"`</mark>, this will cause the credential to be persisted as this name, not <mark style="color:red;">`"customCred"`</mark>. - the refresh name. If the application was to request a new credential it would forcibly refresh every time as the stored credential name is different.&#x20;

```csharp
// BAD EXAMPLE
CredentialStore.RegisterRefresh("customCred", (o) => {
    return new CredentialStoreItem() { Name = "DiffName", Expiration = DateTimeOffset.UtcNow.AddHours(1) };
});

//Forcibly calls refresh method every time, since the persisted name is different
var c = CredentialStore.GetCredential("customCred");

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.perigee.software/core-modules/credential-management/troubleshooting-credentials.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
