Hi guys! I´m trying to understand how to get third...
# support-questions-legacy
a
Hi guys! I´m trying to understand how to get third-party user´s first and last name... I´ve enabled metadata feature and added scope https://www.googleapis.com/auth/userinfo.profile to google provider - but those fields are not set. Please suggest what I´m doing wrong?
r
hey @art1c0 you need to set those manually in the user metadata recipe.
a
thanks @rp_st , but how do i get them? is there an example gist or something?
r
which recipe are you using?
a
ThirdPartyEmailPassword
a
ok, and after "let accessToken =..." i have to call google api to get the names, right? and the same goes to apple as well?
r
yes
a
thank you! by the way, under the hood supertokens use the new Google Identity Services for Web solution, or rely on the old Google Sign-In JavaScript platform library for Web is set to be deprecated after March 31, 2023 ?
r
@sattvikc can answer this.
s
will get back in a moment
@art1c0 you are right about fetching name for google. but for apple, there is no separate API that provides user info. Also, it's sent back in a different way. May I know which language are you using for backend? I'll help you with a sample code snippet which you could use as a reference
a
i use nest.js
s
and about the google identity service, we don't use the javascript platform library. we use standard open-id/oauth2 approach.
I'm little busy right now, I'll share the apple snippet whenever I get some time to look into it.
a
@sattvikc if i´d like to work with both google and apple in the same override, i have to distinguish them by input.provider.id, right?
s
right
a
i have success with google, by change do you have time to give me apple example, please?
@sattvikc i tried to set scope in config as 'email name' and noticed that in the URL it appears as 'email+name', however according to apple docs it has to be like 'email%20name' https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_js/incorporating_sign_in_with_apple_into_other_platforms#3332113 wondering if it can cause an issue.
s
scope should be an array, plz set it to ['email', 'name']
a
@sattvikc i set it to array for both google and apple, however resulting URLs differ: https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?scope=email%20profile... https://appleid.apple.com/auth/authorize?scope=email+name... google's one seems right, but apple's not. not sure where this happens, maybe on supertokens side which makes the redirect
@sattvikc anyway, if you have working example of getting apple user fullname - that means it works with both + and %20... could you please share the example
s
+ and %20 mean the same in the URL
but, the way name is returned by the apple is different. it would need some amount of time to write the sample. I'll share whenever I get some time for this.
r
hey @art1c0 - unfortunately we won't be able to help you with the name issue with apple at the moment. You can try and solve it yourself using our overrides feature. That being said, we are working on fixing this issue entirely in our SDK and will release this in 1-2 months time
a
@rp_st ok i will try.. please suggest how can i get original apple response in the override function?
@sattvikc according to apple docs, user name should be in the response: https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_js/incorporating_sign_in_with_apple_into_other_platforms#3332115 user - A JSON string containing the data requested in the scope property. The returned data is in the following format: { "name": { "firstName": string, "lastName": string }, "email": string }
@rp_st @sattvikc after some investigation i found that user data goes from apple via post request to the redirectURI, which is https://supertokens.io/dev/oauth/redirect-to-app - if i try to change it apple returns error, so i guess it's tied to client_id internally? is there a way to change this uri to handle the response on my side?
r
You need to use your own apple keys and can set the callback url on your side
a
@rp_st if i specify my own redirect URI - what is the default path on my own supertokens setup to handle that? or this handler exists only on your site?
r
It will be your apiDomain/auth/callback/apple
(This is also mentioned in our docs)
a
thank you @rp_st ! and the last question: is it possible to get request data from apple using override or i have to fork and modify source code for that?
r
You can get the request data. It should be available in the input.options.req object (if you are using node SDK)
d
@art1c0 did you get this working? I do not see the value in the input.options.req object. I'm calling both getFormData and getJSONBody and don't see it in either. I think the second post is overriding the value. I see a POST to /api/auth/callback/apple and then another to /api/auth/signinup and I can only retrieve the values from the second.
r
Perhaps @sattvikc can help here.
s
may I see your supertokens init and overrides ?
d
r
@sattvikc
d
I've successfully found the value! Is there a recommended way to pipe it to the actual signinupPOST flow?
Copy code
appleRedirectHandlerPOST: async function (input) {
                                console.log("REDIRECT INPUT", input)
                                let result = await originalImplementation.appleRedirectHandlerPOST(input)
                                console.log("REDIRECT RESULT", result)
                                let data = await input.userContext?._default?.request?.getFormData() // [Object: null prototype]
                                let user = { ...data }.user
                                console.log("REDIRECT USER", user)

                                return result
                            }
s
Hi @davido_k, there is no recommended way to pipe it as of now. for now, you could write your own redirect to the frontend and include the data in that. And then the signInUpPOST will also need some tweaking to be able to send that information again. We are working on new interfaces to be able to do this easily. but, that will take some time to release.
other way you could do is use a temporary table that contains email and user Info, populate it in the apple redirect override. and in the sign in up post, once you get the email of the user, use this temporary table to read and populate the user info
d
Thanks! I'll take a closer look at those options
a
hey guys! do you have any suggestions on how to get first and last name of the user using Facebook as a provider? @rp_st
a
thanks! i see you have updated getting these things which is great! however i have no such properties as 'oAuthTokens' and 'rawUserInfoFromProvider' in the response. What version it should be? (node backend and own hosted docker core)
r
15.0 for node SDK
a
i'm on 14... any breaking changes?
r
yup. It is a breaking change. Have a look at the node repo changelog
a
wow man that's huge!
r
yeaa.. a lot has changed! But that's across all features. Focus on the ones you use 😉
a
@rp_st could you please clarify this ´Only supporting FDI 1.17´. do i need to do anything else except updating core to v6 ?
r
you also need to update the frontend SDKs.
to the latest version.
but there aren't too many changes on the frontend.
a
ah ok, thanks. mush have guessed
4 Views