---
title: "retrieveCredentials(forExtendedPANID:completion:)"
framework: threadnetwork
role: symbol
role_heading: Instance Method
path: "threadnetwork/thclient/retrievecredentials(forextendedpanid:completion:)"
---

# retrieveCredentials(forExtendedPANID:completion:)

Requests Thread credentials for an extended Personal Area Network (PAN) ID.

## Declaration

```swift
func retrieveCredentials(forExtendedPANID extendedPANID: Data, completion: @escaping @Sendable (THCredentials?, (any Error)?) -> Void)
```

```swift
func credentials(forExtendedPANID extendedPANID: Data) async throws -> THCredentials
```

## Parameters

- `extendedPANID`: The extended PAN identifier.
- `completion`: The completion handler the framework calls when the credentials become available.

## Discussion

Discussion note: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func credentials(forExtendedPANID extendedPANID: Data) async throws -> THCredentials For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously. When calling this method, an alert appears asking for user permission to access credentials. Call the method as follows: func obtainCredentials(xpanID: Data) async -> (cred: THCredentials? ,err: Error? ) {     let client = THClient()     var credential: THCredentials?     var err:Error?     do {         credential = try await client.credentials(forExtendedPANID: xpanID as Data)     } catch {         err = error     }     return (credential, err) }

## See Also

### Retrieving Credentials

- [isPreferredNetworkAvailable(completion:)](threadnetwork/thclient/ispreferrednetworkavailable(completion:).md)
- [checkPreferredNetwork(forActiveOperationalDataset:completion:)](threadnetwork/thclient/checkpreferrednetwork(foractiveoperationaldataset:completion:).md)
- [retrieveCredentials(forBorderAgent:completion:)](threadnetwork/thclient/retrievecredentials(forborderagent:completion:).md)
- [retrieveAllCredentials(_:)](threadnetwork/thclient/retrieveallcredentials(_:).md)
- [retrievePreferredCredentials(_:)](threadnetwork/thclient/retrievepreferredcredentials(_:).md)
- [retrieveAllActiveCredentials(_:)](threadnetwork/thclient/retrieveallactivecredentials(_:).md)
