Skip to main content
Use this method to read the credentials the SDK holds for the connected customer, so you can forward the accessToken to your own backend and call the MoonPay Platform API server-side on that customer’s behalf. This is an advanced escape hatch. The SDK normally keeps credentials internal and authenticates its own calls (such as getQuote() or getPaymentMethods()) for you. Reach for getCredentials() only when you need to act as the connected customer from your backend, for example to fetch quotes server-side. If the SDK already exposes a method for what you need, use that method instead.
getCredentials() is synchronous. It returns a Result directly, not a Promise, so you do not await it. Every other client method that talks to MoonPay is async.
getCredentials() reads credentials that the connection flow already populated. Establish a connection first with client.getConnection(), and where needed client.connect() or client.setupAuth(). Until a connected-customer accessToken exists, the method returns err({ code: "noActiveSession" }). A guest or connectionRequired session that only holds a clientToken still returns noActiveSession.
Read credentials and call your backend

Fetch quotes from your backend

The supported use case is backend-driven, customer-scoped quoting. Your backend uses the customer’s accessToken as a Bearer token against the Platform API, which is the same authentication the SDK uses internally. See Client-side authentication for the header format.
Backend: quote as the connected customer
The accessToken is a bearer credential, short-lived and scoped to one connected customer. Send it only to your own backend over HTTPS. Don’t log it or persist it long-term. Your backend uses it as a Bearer token against the Platform API.

Parameters

client.getCredentials() takes no arguments.

Result

client.getCredentials() returns a Result<Credentials, GetCredentialsError> synchronously.

Result envelope

Result<Credentials, GetCredentialsError>

Credentials

The tokens the SDK holds for the connected customer. For how these tokens are issued and scoped, see Client credentials.

GetCredentialsError

GetCredentialsError covers the case where no connected-customer session exists yet.
types.ts
Credentials and GetCredentialsError are exported from @moonpay/platform-sdk-web.