You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See below for settings about [the keychain](#keychain) and [PKCE](#pkce).
411
411
412
412
Usage with Alamofire
413
413
--------------------
@@ -457,15 +457,15 @@ dynreg.register(client: oauth2) { params, error in
457
457
PKCE
458
458
----
459
459
460
-
PKCE support is controlled by the `useProofKeyForCodeExchange` property, and the "use_pkce" setting.
460
+
PKCE support is controlled by the `useProofKeyForCodeExchange` property, and the `use_pkce` key in the settings dictionary.
461
461
It is disabled by default. When enabled, a new code verifier string is generated for every authorization request.
462
462
463
463
464
464
Keychain
465
465
--------
466
466
467
467
This framework can transparently use the iOS and macOS keychain.
468
-
It is controlled by the `useKeychain` property, which can be disabled during initialization with the "keychain" setting.
468
+
It is controlled by the `useKeychain` property, which can be disabled during initialization with the `keychain` settings dictionary key.
469
469
Since this is **enabled by default**, if you do _not_ turn it off during initialization, the keychain will be queried for tokens and client credentials related to the authorization URL.
470
470
If you turn it off _after_ initialization, the keychain will be queried for existing tokens, but new tokens will not be written to the keychain.
471
471
@@ -475,14 +475,25 @@ If you have dynamically registered your client and want to start anew, you can c
475
475
Ideally, access tokens get delivered with an "expires_in" parameter that tells you how long the token is valid.
476
476
If it is missing the framework will still use those tokens if one is found in the keychain and not re-perform the OAuth dance.
477
477
You will need to intercept 401s and re-authorize if an access token has expired but the framework has still pulled it from the keychain.
478
-
This behavior can be turned off by supplying "token_assume_unexpired": false in settings or setting `clientConfig.accessTokenAssumeUnexpired` to false.
478
+
This behavior can be turned off by supplying `token_assume_unexpired: false` in settings or setting `clientConfig.accessTokenAssumeUnexpired` to false.
479
479
480
+
These are the settings dictionary keys you can use for more control:
481
+
482
+
-`keychain`: a bool on whether to use keychain or not, true by default
483
+
-`keychain_access_mode`: a string value for keychain kSecAttrAccessible attribute, "kSecAttrAccessibleWhenUnlocked" by default, you can change this to e.g. "kSecAttrAccessibleAfterFirstUnlock" if you need the tokens to be available when the phone is locked.
484
+
-`keychain_access_group`: a string value for keychain kSecAttrAccessGroup attribute, nil by default
485
+
-`keychain_account_for_client_credentials`: the name to use to identify client credentials in the keychain, "clientCredentials" by default
486
+
-`keychain_account_for_tokens`: the name to use to identify the tokens in the keychain, "currentTokens" by default
480
487
481
488
Installation
482
489
------------
483
490
484
-
You can use _git_, _Carthage_ and even _CocoaPods_ to install the framework.
485
-
The preferred way is to use _git_ directly or _Carthage_.
491
+
You can use the _Swift Package Manager_, _git_ or _Carthage_.
492
+
The preferred way is to use the _Swift Package Manager_.
493
+
494
+
#### Swift Package Manager
495
+
496
+
In Xcode 11 and newer, choose "File" from the Xcode Menu, then "Swift Packages" » "Add Package Dependency..." and paste the URL of this repo: `https://github.com/p2/OAuth2.git`. Pick a version and Xcode should do the rest.
486
497
487
498
#### Carthage
488
499
@@ -514,28 +525,6 @@ These three steps are needed to:
514
525
2. Link the framework into your app
515
526
3. Embed the framework in your app when distributing
516
527
517
-
#### CocoaPods
518
-
519
-
CocoaPods was nice back in the days for Obj-C and static libraries, but is overkill in the modern days of Swift and iOS frameworks.
520
-
You can however still use OAuth2 with Cocoapods.
521
-
522
-
Add a `Podfile` that contains at least the following information to the root of your app project, then do `pod install`.
523
-
If you're unfamiliar with CocoaPods, read [using CocoaPods](http://guides.cocoapods.org/using/using-cocoapods.html).
524
-
525
-
```ruby
526
-
platform :ios, '8.0'# or platform :osx, '10.9'
527
-
use_frameworks!
528
-
target `YourApp`do
529
-
pod 'p2.OAuth2', '~> 4.2'
530
-
end
531
-
```
532
-
533
-
If you want the bleeding edge, use this command for CocoaPods instead – note the `submodules` flag: without it the library will not compile.
534
-
535
-
```ruby
536
-
pod 'p2.OAuth2', :git => 'https://github.com/p2/OAuth2', :submodules => true
0 commit comments