So we submitted our app to IOS Store for review and it got rejected because of one silly reason. Because we were using other social logins and not apple login, so they simply asked us to replace other logins with Apple. Does not that sound bad ? Yeah, we also felt same, and asked but they were strict on this. So , we have to add. But there was a very few docs and only some blogs on medium here with some different languages and not java. So struggling for over a week. I was finally able to done this, so i am now sharing it here, so you all do not face same issues.
Some ideas taken from previous blogs, listed below. Go check.
1. Generate following from Developer account
- Apple Certificate (.p8), that needs to be downloaded
- Apple Client ID
- Apple Key ID
- Apple Team ID
- Apple URL (https://appleid.apple.com)
These all can be generated by going to keys and identifiers menu in Application Developer account of apple
2. Generating a JWT Token for Apple which will work as Client_Secret for apple authentication
3. Authorize request method to get OAuth token as TokenResponse and ID token as ID Token Payload
Note : Apple only sends user obj first time as a JSON string containing email and name. If user not available, email can be get from idToken
4. Response classes
So, i have listed the methods to complete the authorization and get details in backend. I will next add a new post for frontend login also, using some more java code. Let me know if any thing you stuck on.
Let me share here some more code below as a bonus, which will be used with frontend for web authorization flow. I will share frontend code later.
1 Method to generate authorization url with params. Also as we have multiple subdomains in project, adding the state as subDomain for redirecting to subdomain later.
Note: Advantage of this method is that, by using a single domain and redirect url, we can achieve Apple sign(Any other social Sign in also) for multiple domains using popup, to catch authorization params in the url after redirection.
i will add code for popup later in frontend part
2 Method for handling redirect from form_post to get redirect with authorization params as query params in popup window url.
So, this is it the secret bonus method, many people still looking for.
So this was all for now, i hope it will help you in achieving apple sign in. There are some more issues you may face, that i will address in later posts. You can comment any issue you may face and i will try to help as much as i can. Feel free to like and show love, your support inspires me to write more and share like this. Thanks for reading.
Do visit our another technical Blog Tekraze.com for more posts
Originally published at Medium
Top comments (0)