# 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](https://docs.perigee.software/core-modules/perigeeapplication).&#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");

```
