GET returning an error 401

So here’s my code

async function getProfile() {
const accessToken = “{REMOVED FOR SECURITY}”;
const response = await fetch(‘’, {
headers: {
Authorization: Bearer ${accessToken},
Accept: ‘application/json’

                    const user = await response.json();
                    const firstName = user.profile.firstName;
                    const lastName = user.profile.lastName;
                    const email =;
                    const phone = user.profile.mobilePhone || 'N/A';

                    console.log({ firstName, lastName, email, phone });


the issue is when I run this I get an error 401(unathorized) from Okta, so I am running this off of local host and have it set to a trust url already. any idea on why this is happeing? Thanks!

I also have this code run when there is already an active user session.

UPDATE: So as it turns out with this GET you actually put “SSWS” in place of “Bearer” along with the apitoken

1 Like

I do want to note that you can use Bearer {accessToken} in the auth header for this request. Using an SSWS token is good if the admin needs to make the call, but end-users can also use this endpoint

In order to get a token that you can use against this endpoint, the token will…

  1. need to be returned by the Org Authorization server (e.g. https://oktadomain/oauth2/v1/authorize)
  2. contain the necessary scope, in this case
  3. be issued to the user you want to get information about.

For more info, see Implement OAuth for Okta | Okta Developer