a-tokyo / react-apple-signin-auth

 Apple signin for React using the official Apple JS SDK

Home Page:https://a-tokyo.github.io/react-apple-signin-auth

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

appleAuthHelpers requires manual importing of apple auth script to function properly

Maclay74 opened this issue · comments

And it's quite obvious why.

You inject Apple's script only when rendering button.
Please make if configurable, would be nice to export configuration method which can be called from useEffect or something.

Anyway, now it doesn't work at all, my workaround is to inject it manually.

@Maclay74 The simple solution for this is for you to import the apple script.

We made a conscious decision of only importing the script with the button since this is how most people will use the library.

The appleAuthHelpers is basically an extra utility function that eases the deal with Apple Auth, it should not import the script.

I don't see the Gain in making the script configurable since people can easily render the script correct?

I appreciate your point, but it's wrong.

I've been looking for a library that can provide me with such feature as appleAuthHelpers because default UI doesn't fit my goals.

Since you have declared it not just by exporting, but as mentioning in documentation, it should at least state that injecting script it mandatory. For now, it's just silent void after calling the function.

So the reason "most people use it this way, although we have another one" isn't a solid one.

I see a few ways of gently addressing it:

  1. The most appropriate solution - make a hook which will return appleAuthHelpers instead of importing it. This hook will internally inject script and init Apple SDK. Both default UI and custom solutions will take advantage of it.
  2. Export useScript as useAppleScript so people could register it on their own.
  3. Throw an error if script isn't injected when singIn is called.
  4. Menton in README the proper way of injecting script, maybe with source code.

So, please, I just don't want anybody else to waste their time into reading sources.

Thanks.

Thanks for your input @Maclay74 , The clear purpose of appleAuthHelpers is to use the functionality without using the UI or relying on React, which clearly means it doesn't have react related code like hooks or script loading.

I think adding a documentation note would be enough, I would love to work on extra features like react-hooks once I have more tine.

You are more than welcome to submit a PR with the proposed solution you mentioned. This would help fast track the procedure if you don't want anybody else to waste their time into reading sources like you mentioned.

Side note: the title of the issue should be corrected to be clear for other users. AppleAuthHelpers indeed works, you just need to import the apple script.

Thanks.

I updated the documentation and exported the Apple Script URL. Feel free to reopen the issue if you have further discussion points, also you can open a PR anytime.

Thanks for your work on this package! I have to say that I overlooked the one line at the end of the paragraph that says you must import the script yourself. I would combine the two code snippets in the readme so that you can clearly see that appleAuthHelpers is being used in the same file as useScript

Caused me to spend more time than I should have figuring out what was going on.