amplify-swift
amplify-swift copied to clipboard
`AuthUser.username` property returns a UUID on iOS but returns an email address on Android
Describe the bug
Hi,
I'm working on two native apps that both use the latest version of the Amplify SDK with AWS Cognito as the auth provider.
On both platforms we use the username
property of the AuthUser
to show the user's email address in the UI. On Android this works as expected, but on iOS it returns the same value of the userId
property - which is a UUID.
Steps To Reproduce
Steps to reproduce the behavior:
1. Log in using an AWS Cognito auth provider with the Amplify SDK
2. Get the current user: `let user = Amplify.Auth.getCurrentUser()`
3. Print the user's username: `print(user?.username)`
4. See the user's userId (UUID)
Expected behavior
- To see the user's email address
Amplify Framework Version
1.28.1
Amplify Categories
Auth
Dependency manager
Swift PM
Swift version
5.7
CLI version
n/a
Xcode version
14.0
Relevant log output
No response
Is this a regression?
No
Regression additional context
No response
Device
iPhone 11, iPhone 13 simulator
iOS Version
iOS 16
Specific to simulators
No
Additional context
No response
@mbernson
The team is actively working on unifying getCurrentUser
API behaviour on all platforms. We will post an update on the ticket after the change has been implemented.
Meanwhile, I would like to recommend to use Fetch Attributes API to get logged in user details.
This has been identified as a feature request. If this feature is important to you, we strongly encourage you to give a 👍 reaction on the request. This helps us prioritize new features most important to you. Thank you!
Amplify 2.0 has been released which normalizes what values are returned in the getCurrentUser
API. The API will now use the accessToken
to determine the userId
and username
values. Adding the reference to the implementation as well.