# How to retrieve PublicKey and when login in with passkey

**URL:** <https://community.auth0.com/t/how-to-retrieve-publickey-and-when-login-in-with-passkey/185442>\
**Category:** Get Help\
**Tags:** actions-management-api, management-api\
**Created:** [April 14, 2025, 11:04am UTC](https://community.auth0.com/t/how-to-retrieve-publickey-and-when-login-in-with-passkey/185442 "2025-04-14T11:04:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![div-Leo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/div-leo/32/74253_2.png) [@div-Leo](https://community.auth0.com/u/div-Leo)\
**Post date:** [April 14, 2025, 11:04am UTC](https://community.auth0.com/t/how-to-retrieve-publickey-and-when-login-in-with-passkey/185442/1 "2025-04-14T11:04:01Z")

</div>

I need to access the passkey’s PublicKey from the clinet and I have been trying to implement the best solution.

I followed the nextjs on github: auth0-nextjs-samples  
(Note for the repo owners, there’s a mistake in the tutoria when setting app the Apps URLs, the callback suggested is `api/auth/callback` but reading the codesourse is `auth/callback`)

My understanding is that I need to call `/api/v2/users/${user.sub}/authentication-methods` and configure the Auth setup accordingly:

- Application type: Regular Web Application
- Enable passkey DB (with Authentication Profile: Identifier First )
- Authentication method: any other than None (using “Client Secret Post”)
- Set Grant Type to “Client Credentials”
- Passed in env.local the relative scope, intents:
  - AUTH0\_SCOPE=‘openid profile email authentication\_methods’
  - AUTH0\_SCOPE=‘openid profile email read:authentication\_methods’

- I needed to fetch the access\_tocken from `{process.env.AUDIENCE}/oauth/token` with grant\_type: ‘client\_credentials’ passing the client\_secret and the client\_id.
- I’m calling this endpoint from a Next.js server to make sure it was not running on the browser

Finally I manage, but I want to understand what of all this is necessary and what not.

Using `auth0.getAccessToken()` from `@auth0/nextjs-auth0/server` gave me this error:  
{  
“statusCode”: 403,  
“error”: “Forbidden”,  
“message”: “Insufficient scope, expected any of: read:authentication\_methods”,  
“errorCode”: “insufficient\_scope”  
}

I matched the 2 tokens from getAccessToken() and the fetch(‘…/oauth/token’) and they are different. Is that expected? why are they different?

I was getting the same error when trying with a client only React app and Application type set to SPA.

Can anyone tell me if what I have is correct or I went down the wrong road?  
Thanks!

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [April 14, 2025, 10:37pm UTC](https://community.auth0.com/t/how-to-retrieve-publickey-and-when-login-in-with-passkey/185442/3 "2025-04-14T22:37:26Z")

</div>

Hi @div-Leo,

Thanks for your question.

The error you encountered states that the request failed because it had an insufficient scope. Specifically, it was expecting the `read:authentication_methods` scope.

It’s possible that your application does not have this scope assigned to it. You can check by going to your application settings and clicking on the APIs tab. On that page, select the Management API and ensure that the `read:authentication_methods` scope is checked.

> [@div-Leo](#):
>
> I matched the 2 tokens from getAccessToken() and the fetch(‘…/oauth/token’) and they are different. Is that expected? why are they different?

It depends on the scenario. If you made a request to the `/oauth/token` and then called the getAccessToken() within the same user session, you may get the same token only if both requests use the same audience, scope, and grant type.

However, the tokens might be different if getAccessToken() silently authenticates or uses different parameters, such as for the audience, scopes, or grant type.

I’m curious: What made the two tokens different from each other? Were there any specific claims you noticed that were different?

Kind regards,  
Rueben

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [April 28, 2025, 10:38pm UTC](https://community.auth0.com/t/how-to-retrieve-publickey-and-when-login-in-with-passkey/185442/4 "2025-04-28T22:38:27Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
