Hello everybody, I would like to use social login...
# ory-network
c
Hello everybody, I would like to use social logins e.g. Microsoft, Google, and Apple and get the email address and the profile picture. Email address works, but I cannot get I was hoping to get along with a new entry (shown in bold) in the identity schema:
{
"$id": "<https://schemas.ory.sh/presets/kratos/identity.email.schema.json>",
"title": "Person",
"type": "object",
"properties": {
"traits": {
"type": "object",
"properties": {
"email": {
"type": "string",
"format": "email",
"title": "E-Mail",
"<http://ory.sh/kratos|ory.sh/kratos>": {
"credentials": {
"password": {
"identifier": true
},
"webauthn": {
"identifier": true
},
"totp": {
"account_name": true
}
},
"recovery": {
"via": "email"
},
"verification": {
"via": "email"
}
},
"maxLength": 320
},
"picture": {
"type": "string",
"format": "url",
"title": "Profile picture"
}
},
"required": [
"email"
],
"additionalProperties": false
}
}
}
I then configured e.g. Microsoft as follows:
local claims = std.extVar('claims');
{
identity: {
traits: {
[if 'email' in claims then 'email' else null]: claims.email,
[if 'picture' in claims then 'picture' else null]: claims.picture,
},
},
}
But even if I use a static string as value for picture, the only trait that is reported back is
email
. Am I missing something? Did I get the idea right? This might be a stupid question, but I am still pretty new to Ory and I might not be aware of all basic concepts.
p
Hey @curved-wolf-66275 that is a good question, I would need to check which claims are being mapped from Microsoft since they might not provide a "picture" claim. Or the name they provide is something other than "picture" which we aren't mapping.
We seem to use the OAuth token retrieved from Microsoft to call their API
Copy code
GET <https://graph.microsoft.com/v1.0/me>
https://learn.microsoft.com/en-us/graph/api/user-get?view=graph-rest-1.0&amp;tabs=http#example-2-signed-in-user-request This does not seem to return any data regarding a profile picture. It seems they have a separate API for getting the profile picture https://learn.microsoft.com/en-us/graph/api/profilephoto-get?view=graph-rest-1.0. You will most likely need to update the identity after registration using the token Ory retrieved when the user linked their social provider - https://www.ory.sh/docs/kratos/social-signin/get-tokens
c
Thank you so much for your help! Did I get the
traits
section right? I was aware of that separate API, but I am not eager to go for an additional API: my goal is to support different social sign-ins and add new ones when needed. But I want to do that by configuration, not by changing my code. In case there is not common way to support all social IdPs, I might look into e. g. Gravartar as a fallback.
p
the
traits
look alright 🙂 Ory can support multiple Social sign-ins, but not all of them provide all user details in the claims object. To support more, I would suggest opening an issue https://github.com/ory/network/issues. I would suggest just doing the fallback to Gravatar for now, since we don't map data from all social providers and their specific user objects.
c
👍🏻 Thank you!