-
Notifications
You must be signed in to change notification settings - Fork 267
Update Auth0.podspec #1281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Update Auth0.podspec #1281
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -33,5 +33,129 @@ Pod::Spec.new do |s| | |||||
| s.visionos.deployment_target = '1.0' | ||||||
| s.visionos.pod_target_xcconfig = { | ||||||
| 'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'WEB_AUTH_PLATFORM PASSKEYS_PLATFORM' | ||||||
|
Comment on lines
+33
to
+35
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s.visionos.deployment_target = '1.0'
Comment on lines
+33
to
+35
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s.visionos.deployment_target = '1.0'
Comment on lines
+33
to
+35
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s.visionos.deployment_target = '1.0'
Comment on lines
+33
to
+35
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s.visionos.deployment_target = '1.0'
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Comment on lines
+33
to
+35
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s.visionos.deployment_target = '1.0'
Comment on lines
+33
to
+35
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s.visionos.deployment_target = '1.0' |
||||||
| } | ||||||
| end | ||||||
| }.package(url: "https://github.com/auth0/Auth0.swift", from: "2.22.0") | ||||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||||||
| <plist version="1.0"> | ||||||
| <dict> | ||||||
| <key>ClientId</key> | ||||||
| <string>VTG0v4XJMwkQsmsJHzHNpVt7jiEsaTHw</string> | ||||||
| <key>Domain</key> | ||||||
| <string>dev-rqdegco5aoxhffiq.us.auth0.com</string> | ||||||
| <key>CallbackMode</key> | ||||||
| <string>custom-scheme</string> | ||||||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||||||
| </dict>import SwiftUI | ||||||
| import Auth0 | ||||||
|
|
||||||
| struct ContentView: View { | ||||||
| // Stores credentials in the Keychain so the session survives app restarts. | ||||||
| private let credentialsManager = CredentialsManager(authentication: Auth0.authentication()) | ||||||
|
|
||||||
| // The user profile is read straight from the stored ID token's claims. | ||||||
| @State private var user: UserInfo? | ||||||
| @State private var isLoading = true | ||||||
| @State private var errorMessage: String? | ||||||
|
|
||||||
| private static let useUniversalLinks: Bool = { | ||||||
| guard let path = Bundle.main.path(forResource: "Auth0", ofType: "plist"), | ||||||
| let values = NSDictionary(contentsOfFile: path) else { | ||||||
| return false | ||||||
| } | ||||||
| return values["CallbackMode"] as? String == "universal-links" | ||||||
| }() | ||||||
|
|
||||||
| private func webAuth() -> WebAuth { | ||||||
| let webAuth = Auth0.webAuth() | ||||||
| return Self.useUniversalLinks ? webAuth.useHTTPS() : webAuth | ||||||
| } | ||||||
|
|
||||||
| var body: some View { | ||||||
| VStack(spacing: 16) { | ||||||
| if isLoading { | ||||||
| Text("Loading...") | ||||||
| } else if let user { | ||||||
| Text("Logged in as \(user.email ?? "unknown")") | ||||||
| .font(.title) | ||||||
| VStack(alignment: .leading, spacing: 4) { | ||||||
| Text("sub: \(user.sub)") | ||||||
| Text("name: \(user.name ?? "")") | ||||||
| Text("email: \(user.email ?? "")") | ||||||
| Text("email_verified: \(user.emailVerified.map(String.init) ?? "")") | ||||||
| Text("nickname: \(user.nickname ?? "")") | ||||||
| Text("picture: \(user.picture?.absoluteString ?? "")") | ||||||
| } | ||||||
| .font(.body) | ||||||
| Button("Log Out", action: logout) | ||||||
| .font(.title3) | ||||||
| } else { | ||||||
| Button("Sign Up") { login(screenHint: "signup") } | ||||||
| .font(.title3) | ||||||
| Button("Log In") { login() } | ||||||
| .font(.title3) | ||||||
| Text(Self.useUniversalLinks | ||||||
| ? "Using HTTPS (Universal Links) for callbacks" | ||||||
| : "Using custom URL scheme for callbacks") | ||||||
| .font(.footnote) | ||||||
| .foregroundColor(.secondary) | ||||||
| } | ||||||
| if let errorMessage { | ||||||
| Text(errorMessage).foregroundColor(.red).font(.callout) | ||||||
| } | ||||||
| } | ||||||
| .padding(.horizontal, 16) | ||||||
| // Renew the session from the Keychain on launch. `credentials()` uses the | ||||||
| // stored refresh token to silently renew an expired access token (and stores | ||||||
| // the result), so the session survives past ID token expiry. `user` is read | ||||||
| // from the returned credentials' ID token claims. | ||||||
| .onAppear { | ||||||
| guard credentialsManager.canRenew() else { | ||||||
| isLoading = false | ||||||
| return | ||||||
| } | ||||||
| credentialsManager.credentials { result in | ||||||
| if case .success = result { | ||||||
| user = credentialsManager.user | ||||||
| } | ||||||
| isLoading = false | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| private func login(screenHint: String? = nil) { | ||||||
| errorMessage = nil | ||||||
| var webAuth = webAuth() | ||||||
| .scope("openid profile email offline_access") | ||||||
| if let screenHint { | ||||||
| webAuth = webAuth.parameters(["screen_hint": screenHint]) | ||||||
| } | ||||||
| webAuth.start { result in | ||||||
| switch result { | ||||||
| case .success(let credentials): | ||||||
| errorMessage = nil | ||||||
| _ = credentialsManager.store(credentials: credentials) | ||||||
| user = credentialsManager.user | ||||||
| case .failure(let error): | ||||||
| errorMessage = error.localizedDescription | ||||||
| print("Login failed: \(error)") | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| private func logout() { | ||||||
| errorMessage = nil | ||||||
| webAuth() | ||||||
| .clearSession { result in | ||||||
| switch result { | ||||||
| case .success: | ||||||
| errorMessage = nil | ||||||
| _ = credentialsManager.clear() | ||||||
| user = nil | ||||||
| case .failure(let error): | ||||||
| errorMessage = error.localizedDescription | ||||||
| print("Logout failed: \(error)") | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| </plist> | ||||||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s.visionos.deployment_target = '1.0'
s.visionos.pod_target_xcconfig = {
'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'WEB_AUTH_PLATFORM PASSKEYS_PLATFORM'
}