DEV Community

Cover image for How to add "signin with apple" to your website

How to add "signin with apple" to your website

Arpit on August 17, 2020

Why Use Apple Many websites have provide users a way to sign in to their applications via third party services like Google, Twitter, Git...
Collapse
 
victortommasi profile image
tommasi.dev

Thank you so much! Saved my day! I wasn't sure how to do the sign in process with popup option setted true.

PS: Fix the note:
"The user object is only sent the first time a user logs in, the rest of the times apple will only send the authentication object.". Instead of "authentication" object write "authorization" object.

Collapse
 
heyitsarpit profile image
Arpit

Thanks for spotting the mistake, updated!

Collapse
 
aidv profile image
aidv

On mobile safari, it behaves quite weird.

After sign in is successful, the error "popup_closed_by_user" is fired, and the page redirects to the redirect_uri, which is practically a blank white page.

Any ideas on why this is happening?

Collapse
 
romalyt profile image
Roman

Oh my god, thank you! Saved my day as well!

Collapse
 
jezmck profile image
Jez McKean

The key takeaway for me was

Apple makes a POST request to the redirectURI that you specify, normally you'd have a link to your backend API where the data gets posted, however we can bypass this and capture the information on the frontend by using the usePopup flag. This will instead capture apple's response on the client side.

Collapse
 
abc_abc_ee7ab7696b1fafcf9 profile image
abc abc • Edited

Hello sir i am following your blog for adding sign in with apple but after putting email and password and after that clicked on continue then after page disappears and not signed in to website
Also not getting any authorization object or user object
Please help me in that ...

Collapse
 
diana0604 profile image
Diana0604

I've got a question. If you didn't have the popup, you'd still have the option for the redirectURI to be a frontend url, right? I have done this in the past for Twitter and you can just redirect to the same page you're in

Collapse
 
__e10aa8198 profile image
Андрей некрасов • Edited

Do I understand correctly that to create an Sign In with Apple to website I need a developer account? Developer account costs $100.

Collapse
 
marcosfitzsimons profile image
Marcos Fitzsimons

Yes. You need paid developer account

Collapse
 
pubkey profile image
Daniel M

Can you show how to do the login without having to use the js file from the apple cdn?
Like manually opening the popup and handling the events.

Collapse
 
abhijith profile image
Abhijith cv

did you got this

Collapse
 
frankgracy profile image
Grace Frank

I really appreicate this detailed step by step process. Even apple documentation dosent explain this as well as you did.