@gargoyle is it safe using directly credentials.user
to identify a user on app server without doing any validation with Apple servers? Iâm using native AuthenticationServices
and I donât understand how to use identityToken
and authorizationCode
. Thanks!
credentials.user is the ID that you store for the user. Itâs where youâd historically have had them use an email address to create an ID in the past. There is no security around that user though. Itâs a string of characters that anybody could spoof if they knew what it was.
The identityToken and authorizationCode are for the OAuth type flows that youâd handle server side. There a potential bug right now with the server side expiration dates that Iâm working with Apple, and once I have that resolved Iâm planning to post a tutorial on handling server side via Vapor.
If you are only on the device then you can trust the user provided. If youâre making a REST call to your backend server, then you need to implement the authorization via Appleâs REST API.
Yes, Iâm making REST call to my backend server⊠so I need to implement OAuth flow. Thanks for your answer, Iâll wait for your Vapor tutorial and then Iâll try to make it work in PHP
I fixed the issue but I do not quite understand the whole process of Sign in with Apple.
1.) I check if there is already an Apple ID shared for login with this app.
2.) If not I request the credentials I need and store them in the local keychain.
3.) I was always looking for an entry for my app in Settings => Passwords & Accounts. But I realized that this has nothing to do with it.
4.) When my app is starting I am always checking if there is an entry for my app in the local keychain.
5.) So I donât need to store anything in a seperate/external database.
Is that right? Did i get it?
Thanks in advance,
steve46
Iâm also having the exact same problem. Try running the final project and it will show the error:
How did you fix the issue? Iâm having same issue.
In Xcode 11.4 this line causes an error; âValue of type âEnvironmentValuesâ has no member âwindowââ
@Environment(\.window) var window: UIWindow?
How do you suggest populating the window variable?
Edit:
Nevermind, I hadnât created the extension from EnvironmentWindowKey.swift
I am having the same issueâŠ
I tried
Xcode 11.3.1 (11C504)
Xcode 11.4 beta 2 (11N123k)
âContentViewâ is not a member type of âSignInWithAppleâ
BuildError: Failed to build ContentView.swift
Compiling failed: âContentViewâ is not a member type of âSignInWithAppleâ
failedToBuildDylib: /Users/brent/Library/Developer/Xcode/DerivedData/SignInWithApple-gbyfszqmlonwrkbcsvqpgaudyrbu/Build/Intermediates.noindex/Previews/SignInWithApple/Intermediates.noindex/SignInWithApple.build/Debug-iphonesimulator/SignInWithApple.build/Objects-normal/x86_64/ContentView.2.preview-thunk.swift:89:41: error: âContentViewâ is not a member type of âSignInWithAppleâ
typealias ContentView = SignInWithApple.ContentView
~~~~~~~~~~~~~~~ ^
/Users/brent/Library/Developer/Xcode/DerivedData/SignInWithApple-gbyfszqmlonwrkbcsvqpgaudyrbu/Build/Intermediates.noindex/Previews/SignInWithApple/Intermediates.noindex/SignInWithApple.build/Debug-iphonesimulator/SignInWithApple.build/Objects-normal/x86_64/ContentView.2.preview-thunk.swift:18:6: error: replaced function âperformSignIn(using:)â could not be found
@_dynamicReplacement(for: performSignIn(using:)) private func __preview__performSignIn(using requests: [ASAuthorizationRequest]) {
^
/Users/brent/Library/Developer/Xcode/DerivedData/SignInWithApple-gbyfszqmlonwrkbcsvqpgaudyrbu/Build/Intermediates.noindex/Previews/SignInWithApple/Intermediates.noindex/SignInWithApple.build/Debug-iphonesimulator/SignInWithApple.build/Objects-normal/x86_64/ContentView.2.preview-thunk.swift:38:6: error: replaced function âperformExistingAccountSetupFlows()â could not be found
@_dynamicReplacement(for: performExistingAccountSetupFlows()) private func __preview__performExistingAccountSetupFlows() {
^
/Users/brent/Library/Developer/Xcode/DerivedData/SignInWithApple-gbyfszqmlonwrkbcsvqpgaudyrbu/Build/Intermediates.noindex/Previews/SignInWithApple/Intermediates.noindex/SignInWithApple.build/Debug-iphonesimulator/SignInWithApple.build/Objects-normal/x86_64/ContentView.2.preview-thunk.swift:55:6: error: replaced function âshowAppleLogin()â could not be found
@_dynamicReplacement(for: showAppleLogin()) private func __preview__showAppleLogin() {
^
/Users/brent/Library/Developer/Xcode/DerivedData/SignInWithApple-gbyfszqmlonwrkbcsvqpgaudyrbu/Build/Intermediates.noindex/Previews/SignInWithApple/Intermediates.noindex/SignInWithApple.build/Debug-iphonesimulator/SignInWithApple.build/Objects-normal/x86_64/ContentView.2.preview-thunk.swift:66:6: error: replaced accessor for âbodyâ could not be found
@_dynamicReplacement(for: body) private var __preview__body: some View {
^
/Users/brent/Downloads/SignInWithApple/final/SignInWithApple/ContentView.swift:79:5: error: use of unresolved identifier âappleSignInDelegatesâ
appleSignInDelegates = SignInWithAppleDelegates(window: window) { success in
^~~~~~~~~~~~~~~~~~~~
/Users/brent/Downloads/SignInWithApple/final/SignInWithApple/ContentView.swift:79:61: error: use of unresolved identifier âwindowâ
appleSignInDelegates = SignInWithAppleDelegates(window: window) { success in
^~~~~~
/Users/brent/Downloads/SignInWithApple/final/SignInWithApple/ContentView.swift:88:27: error: use of unresolved identifier âappleSignInDelegatesâ
controller.delegate = appleSignInDelegates
^~~~~~~~~~~~~~~~~~~~
/Users/brent/Downloads/SignInWithApple/final/SignInWithApple/ContentView.swift:89:46: error: use of unresolved identifier âappleSignInDelegatesâ
controller.presentationContextProvider = appleSignInDelegates
^~~~~~~~~~~~~~~~~~~~
/Users/brent/Downloads/SignInWithApple/final/SignInWithApple/ContentView.swift:61:5: error: use of unresolved identifier âperformSignInâ
performSignIn(using: [request])
^~~~~~~~~~~~~
/Users/brent/Downloads/SignInWithApple/final/SignInWithApple/ContentView.swift:49:34: error: use of unresolved identifier âshowAppleLoginâ
.onTapGesture(perform: showAppleLogin)
^~~~~~~~~~~~~~
I am having a difficult time figuring out how to throw the UIWindow back into a regular âhome screenâ that uses traditional SwiftUI. I know that you need to utilize UIKit to implement the sign in with apple button, but once authorization is successful/failed, I cannot seem to return a SwiftUI view.
The best I have been able to do is set a new Bool state in the ContentView for authentication success which triggers in the performSignIn private func if success. Thinking that would work, it seems to only return my new swift screen on the bottom half of the screen, but keeps the login screen on the top half and never refreshes away.
Any ideas?
Thanks for you help!
Is there any tutorial for implementing sign in with apple for iOS 12 devices. I am trying to figure it out but unfortunately itâs not working as expected. I followed the tutorial from here
Sign In With Apple
Iâm getting invalid redirect_uri however I didnât found anywhere what should we pass in the request for redirect_uri paramer. Iâm calling the request from iPhone 6. Does anyone knows any solution to this ?
@rahulvyas The redirect_uri stuff is only used for the web based sign in. If you follow the tutorial it shows you what you need for iOS. if youâre not using swiftui you can just leave those parts out.
For iOS 13 youâre right we donât need to code much, Iâm looking for support in iOS 12 and older OSeâs.
If you read the docs it says we need to hit a URL and it will work something like facebook authorization. When I hit url (Using UIApplication openUrl method) Iâm getting invalid redirect_uri error. If you know any other way to integrate it into iOS 12 and older devices do let me knowâŠ
So youâre using the web apiâs then, which is out of scope for this article. In your Apple developer portal, though, you specify the redirect URI to use, and itâs kind of painful to get that all working.
Yes, Itâs out of scope I know, all I want is help from someone who has implemented it for iOS 12 and older OS devices. Also we are having issue in backend as well to get key from .P8 file. Do you have any idea about it ?
@hidrodixtion @chipcastille @perlguy Do you still have issues with this?
Hi, I canât remember offhand exactly what issue I was having. I will try to go back through the tutorial and see if things have changed.
Brent
I have a question, maybe is a stupid question but I canât figure it out. I want to show the username in as text in my HomeView.swift. How can I get the username from the KeyChain?
@gargoyle Can you please help with this when you get a chance? Thank you - much appreciated! :]
@rahulvyas Do you still have issues with this?
@tommydr I wouldnât do that, honestly. When you authenticate with your backend server have it send back the display name for the person and show that.