Apple Sign In


Check out the new free Apple Sign In

1 Like

Is there any way to get the credentials passed from apple? ( )

I’m trying to implement an authentication flow similar to what’s outlined at

What do you mean by “credentials”? See docs

What I meant are the additional tokens Apple is passing on to the app after authenticating:

  • identityToken (JWT)
  • authorizationCode
  • email

When trying your plugin and checking out the docs, I only see references to name and user id.

PS: Is it possible to build the plugin from source or is only the demo on GitHub?

Added identityToken, authorizationCode to docs and plugin

will be returned as event.identityToken, event.authorizationCode

email is returned as if you put in “email” or “nameAndEmail”

Great, thanks. I got it to work.

I was also confused by the fact that email/name aren’t returned every time (in case anybody is also affected, this is an apple thing: )

It appears that we have until June 30, 2020 to implement Apple Sign In for iOS and Mac apps, that is, if you offer FB login or email login, we must support Apple Sign In.

Apps that authenticate or set up user accounts must support Sign in with Apple if required by guideline 4.8 of the App Store Review Guidelines. Article here:

@Scott_Harrison I saw this note in your build.settings.

  1. Do we really need to add Apple Pay to our provisioning file for the app?

entitlements =
[“”] = {“Default”}, – make sure provisioning profile supports apple pay?

  1. I also only saw “name” and “user” in the online docs. If I want the name and email, do I use “nameAndEmail” as you wrote above?

  2. will it be the full name?

I have this ready to go in my code; but I just wanted to double-check the provisioning issue here before I try and create a new build.

  1. does it work in TestFlight before a release?
  1. yes read

  2. yes use nameAndEmail

  3. yes

  4. yes

@Scott_Harrison I’m creating a detailed and nice example for your appleSignIn plugin, and just have a couple of issues to resolve.

  1. I’ve looked at the link you provided and Apple Pay is not mentioned anywhere. Are you sure?
  2. I’ve gotten it to work by adding AppleSignIn into the App Identifier. Have you tried this?
  3. Once I have it working on one app, the identical code is not working on the second app. This is the last issue to resolve. Both apps have their AppleSignIn configuration as a primary key. I’ll have to do some tinkering to get both to work, I suppose.

@Scott_Harrison or anyone, how can we check if the iOS version is >=13 before making AppleSignIn available?

This is some code to check if iOS version>=13 before calling AppleSignIn.

: local v=tonumber(system.getInfo(‘platformVersion’))
: if not v then
: --unknown version
: elseif v>=13 then
: --apple sign in button and code can go here
: end

  1. it says it at the top “An entitlement that lets your app use Sign in with Apple.” If you don’t want to use that is up to you.

  2. that what “make sure provisioning profile supports apple pay” means on my documentation

Well, My provisioning profile has Apple Sign In and NOT Apple Pay, and it works fine.

@Scott_Harrison you may want to consider changing your documentation to REMOVE references to “Apple Pay”, as you can see from the Apple App ID Configuration, “Apple Pay” is 3rd from the top, but “Sign In with Apple” is directly underneath Push Notifications must lower on the list. The fact that I have it working in my apps now WITHOUT “Apple Pay” proves it unnecessary and could also confuse other developers; just my two cents.

1 Like

Also, your documentation does not provide any information about what the json.encode(e) returns; in other words, you leave it to developers to figure it out. Here is more info that could help others…

function doAppleSignIn()
  local firstName,lastName,email
  local signIn = require "plugin.appleSignIn"
  local function appleSignInListener(e)
    local ts=json.encode(e)
    print("AppleSignIn Json="..ts)
    if not e.isError then
        if e.fullName and e.fullName.givenName then
        if e.fullName and e.fullName.familyName then
        if then

     return firstName,lastName,email
   if not first then
     -- not successful
     -- successful
doAppleSignIn()  --call the routine above

– Note 1) this code is intended for you to use ONCE per app, and then for you to save the results without having to use AppleSignIn again. I’m not sure it will work a second time, or each time you open the app, without using the other token and authorization-related parameters you can see below. 2) you can also check if e.error=true to see if unsuccessful, but this code works and is more elegant.

Also, here are the 3 results of json.encode(e) that are possible; so your developers can understand how the Apple Sign In will respond in these 3 circumstances:

–when user attempting to hide email (in this case, e.isError and are BOTH=NOT)
AppleSignIn Json={

–when user granted us their email (in this case, e.isError is NOT)
AppleSignIn Json={

–when a user cancels AppleSignIn
AppleSignIn Json={
“error”:“The operation couldn’t be completed. ( error 1001.)”,

Previously this plugin will return a private-relay email address when the user selects ‘hide email address’. But now, there is no private email returned. Email is only returned if the user selects ‘share actual email address’.

It seems to be a problem @ Apple side. Most likely since a vulnerability bug was discovered.

1 Like

Inorder to get the private-email address, you will need to decode the ‘identityToken’ returned from the app. This ‘identityToken’ is acutally the JWT token. Decode and the private-email-address is in there. For PHP, I use the griffin package to decode it.

@Scott_Harrison - can you please implement the fix that @yosu discovered so that you are actually passing a valid email address, rather than requiring developers to have to create some kind of server-based code to translate the identityToken into an actual private-email-address? Please read his two posts carefully to see the problem.

@yosu @troylyndon
Let me break up the questions

First the email stuff with hiding email, it must have been an apple bug because I am running the latest apple version and Xcode and I get an email in both cases. I tested this minutes ago.


second JWT

I am not messing with JWT stuff. There are a ton of libraries for this. I included a link lua library and dozens of other libraries for JS/PHP if you want to handle with on your server.