Skip to content

Commit 5e2f70d

Browse files
committed
Improve documentation
1 parent 624120e commit 5e2f70d

File tree

3 files changed

+20
-29
lines changed

3 files changed

+20
-29
lines changed

README.md

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ OAuth2 frameworks for **macOS**, **iOS** and **tvOS** written in Swift 5.0.
99
- [⤵️ Installation](#installation)
1010
- [🛠 Usage](#usage)
1111
- [🖥 Sample macOS app][sample] (with data loader examples)
12-
- [📱 Sample iOS app](https://github.com/p2/OAuth2PodApp) (using CocoaPods)
1312
- [📖 Technical Documentation](https://p2.github.io/OAuth2)
1413

1514
OAuth2 requires Xcode 10.2, the built framework can be used on **OS X 10.11** or **iOS 8** and later.
@@ -25,7 +24,7 @@ Code compatible with brand new Swift versions are to be found on a separate feat
2524
Usage
2625
-----
2726

28-
To use OAuth2 in your own code, start with `import OAuth2` (use `p2_OAuth2` if you installed _p2.OAuth2_ via CocoaPods) in your source files.
27+
To use OAuth2 in your own code, start with `import OAuth2` in your source files.
2928

3029
In OAuth2 there are [**different kinds of _flows_**](https://tools.ietf.org/html/rfc6749#page-2).
3130
This library supports all of them, make sure you're using the correct one for your use-case and authorization server.
@@ -408,6 +407,7 @@ To customize the _go back_ button when using `OAuth2WebViewController` on iOS 8
408407

409408
oauth2.authConfig.ui.backButton = <# UIBarButtonItem(...) #>
410409

410+
See below for settings about [the keychain](#keychain) and [PKCE](#pkce).
411411

412412
Usage with Alamofire
413413
--------------------
@@ -457,15 +457,15 @@ dynreg.register(client: oauth2) { params, error in
457457
PKCE
458458
----
459459

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.
461461
It is disabled by default. When enabled, a new code verifier string is generated for every authorization request.
462462

463463

464464
Keychain
465465
--------
466466

467467
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.
469469
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.
470470
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.
471471

@@ -475,14 +475,25 @@ If you have dynamically registered your client and want to start anew, you can c
475475
Ideally, access tokens get delivered with an "expires_in" parameter that tells you how long the token is valid.
476476
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.
477477
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.
479479

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
480487

481488
Installation
482489
------------
483490

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.
486497

487498
#### Carthage
488499

@@ -514,28 +525,6 @@ These three steps are needed to:
514525
2. Link the framework into your app
515526
3. Embed the framework in your app when distributing
516527

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
537-
```
538-
539528

540529
License
541530
-------

Sources/Base/OAuth2Base.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ open class OAuth2Base: OAuth2Securable {
171171
- secret_in_body (Bool, false by default, forces the flow to use the request body for the client secret)
172172
- parameters ([String: String], custom request parameters to be added during authorization)
173173
- token_assume_unexpired (Bool, true by default, whether to use access tokens that do not come with an "expires_in" parameter)
174+
- use_pkce (Bool, false by default)
174175

175176
- verbose (Bool, false by default, applies to client logging)
176177
*/

Sources/Flows/OAuth2.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ open class OAuth2: OAuth2Base {
7373
- secret_in_body (Bool, false by default, forces the flow to use the request body for the client secret)
7474
- parameters ([String: String], custom request parameters to be added during authorization)
7575
- token_assume_unexpired (Bool, true by default, whether to use access tokens that do not come with an "expires_in" parameter)
76+
- use_pkce (Bool, false by default)
7677

7778
- verbose (bool, false by default, applies to client logging)
7879
*/

0 commit comments

Comments
 (0)