Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to update user profile with accessToken? #400

Open
0x000111 opened this issue Dec 19, 2023 · 0 comments
Open

How to update user profile with accessToken? #400

0x000111 opened this issue Dec 19, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@0x000111
Copy link

Describe the bug?

Hi Team,
I'm integrating this SDK to my react native application and using browser-sign-in to get the accessToken.
I need update some attribute of user profile.
My OKTA api scope as below:

okta.myAccount.profile.manage
okta.myAccount.profile.read
okta.users.manage
okta.users.manage.self
okta.users.read
okta.users.read.self

And code likes below:

import {
  getAuthClient,
} from '@okta/okta-react-native'

async function updateProfile(accessToken: string) {
    const oktaAuth = getAuthClient()
    oktaAuth.myaccount.updateProfile(oktaAuth, {
            payload: {
              profile: {
                deviceID: 'alert(12345)', // my custom attribute
              },
            },
            accessToken: 'Bearer ' + accessToken,
          }).then((res: any) => {
            console.log(res)
          })
          .catch((err: any) => {
            console.log(err)
          })
}

// after login with browser-sign-in...
updateProfile('my_access_token')
// .....

Then getting below error in console:

[AuthSdkError: AccessToken is required to request MyAccount API endpoints.]

I don't know why get this error and how i fix this problem?

What is expected to happen?

update profile success

What is the actual behavior?

getting error:

[AuthSdkError: AccessToken is required to request MyAccount API endpoints.]

Reproduction Steps?

code as above.

Additional Information?

No response

SDK Version

"@okta/okta-react-native": "^2.9.1",
"okta-auth-js": "7.3.0"

Build Information

No response

@0x000111 0x000111 added the bug Something isn't working label Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant