I am logged in using openid profile email offline_access read:users
scope.
When signing in, I add given_name
and family_name
fields to user_metadata
.
When retrieving user data using userinfo
endpoint I don’t get any of above values in response, even though they are available in the code, but they are empty (nil), only basic values like id, email and pic URL are coming in response. So authentication header, basically, works, but some fields remain nil even though I filled them on sign up.
At the same time - when trying to retrieve user data using Users.get()
API that uses users
endpoint I am getting this error: {"statusCode":400,"error":"Bad Request","message":"Bad HTTP authentication header format","errorCode":"Bearer"}
for no obvious reason since I am logging in with read:users
scope included in the token.
This is basically the code I am using:
private let usernamePasswordConnection = "Username-Password-Authentication"
private let scope = "openid profile email offline_access read:users"
let credentials = try await Auth0
.authentication
.login(usernameOrEmail: email, password: password, realmOrConnection: usernamePasswordConnection, scope: scope)
.start()
// accessToken is now in credentials, all good
credentialsManager.store(credentials: credentials)
// Now retrieving the user info:
let request = Auth0
.users(token: credentials.accessToken)
.get(user.id, fields: ["user_metadata"], include: true)
let meta = try await request.start()
// getting the {"statusCode":400,"error":"Bad Request","message":"Bad HTTP authentication header format","errorCode":"Bearer"} error