auth0 / SimpleKeychain

A simple Keychain wrapper for iOS, macOS, tvOS, and watchOS
https://auth0.github.io/SimpleKeychain
MIT License
576 stars 75 forks source link

Xcode 8 / Swift 2.3 : keychain.setString returns false #34

Closed frederic-adda closed 8 years ago

frederic-adda commented 8 years ago

Hi,

My code was working fine until I migrated to XCode 8 / Swift 2.3. It is inspired from the Auth0 documentation. Basically, now, keychain.setString always return false. So my class property currentIdToken is nil.

Any ideas ?

Thanks Fred

   import Foundation
   import Lock
   import SimpleKeychain

  // Keys for SimpleKeychain
  struct SimpleKeychainKeys {
      static let service          = "Auth0"
      static let id_token         = "id_token"
      static let refresh_token    = "refresh_token"
      static let profile          = "profile"
  }

  class UserAuth {
      private class var keychain: A0SimpleKeychain {
          return A0SimpleKeychain(service: SimpleKeychainKeys.service)
      }

      class var currentIdToken: String? {
          get {
              let idToken = keychain.stringForKey(SimpleKeychainKeys.id_token)
              return idToken
          }
          set {
              if let newIdToken = newValue {
                  keychain.setString(newIdToken, forKey: SimpleKeychainKeys.id_token)
              }
          }
      }
  }
frederic-adda commented 8 years ago

I checked this morning with the new version of Auth0 for XCode 8. Auth0 now works fine, but this issue with SimpleKeyChain remains.

frederic-adda commented 8 years ago

Is there anybody out there?

sarmadmakhdoom commented 8 years ago

I am facing the same issue, please help.

frederic-adda commented 8 years ago

I think I'll switch to Sam Soffes' SAMKeyChain ...

hzalaz commented 8 years ago

@sarmadmakhdoom did you check this in SO http://stackoverflow.com/questions/38456471/secitemadd-always-returns-error-34018-in-xcode-8-beta-gm-in-ios-10-simulator?

Seems this now is required for using the keychain (wonders since it was only required when you shared your keychain).

Tried with Xcode 8GM and works

sarmadmakhdoom commented 8 years ago

Okay I will try that. I think it will solve the problem.

On Friday, 16 September 2016, Hernan Zalazar notifications@github.com wrote:

@sarmadmakhdoom https://github.com/sarmadmakhdoom did you check this in SO http://stackoverflow.com/questions/38456471/secitemadd- always-returns-error-34018-in-xcode-8-beta-gm-in-ios-10-simulator?

Seems this now is required for using the keychain (wonders since it was only required when you shared your keychain).

Tried with Xcode 8GM and works

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/auth0/SimpleKeychain/issues/34#issuecomment-247598802, or mute the thread https://github.com/notifications/unsubscribe-auth/ADXMTx_QdsTfLV-RpcATuqy5LWsXcrB8ks5qqpfXgaJpZM4J85yb .

Sarmad Makhdoom 03344714444 http://sarmad.me/

frederic-adda commented 8 years ago

That worked for me! Thanks