Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Sources/OAuthKit/OAuth+Token.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import Foundation
extension OAuth {

/// A codable type that holds oauth token information.
/// - SeeAlso:
/// [Access Token Response](https://www.oauth.com/oauth2-servers/access-tokens/access-token-response/)
public struct Token: Codable, Equatable, Sendable {

/// The access token string as issued by the authorization server.
Expand Down
23 changes: 23 additions & 0 deletions Sources/OAuthKit/OAuthKit.docc/Extensions/Authorization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# ``OAuthKit/OAuth/Authorization``

@Metadata {
@Available(iOS, introduced: "18.0")
@Available(macOS, introduced: "15.0")
@Available(tvOS, introduced: "18.0")
@Available(visionOS, introduced: "2.0")
@Available(watchOS, introduced: "11.0")
}

## Overview
When an ``OAuth/Provider`` has issued an access ``token``, an `Authorization` is created and stored inside the user's `Keychain`. The `Authorization` holds an access ``token`` along with additional properties about the authorization such as the ``issuer``, when the token was ``issued``, and it's ``expiration``.

- SeeAlso:
[Access Token Response](https://www.oauth.com/oauth2-servers/access-tokens/access-token-response/)

## Topics

### Essentials

- ``OAuth/State``
- ``OAuth/State/authorized(_:_:)``
- ``Foundation/URLRequest/addAuthorization(auth:)``
29 changes: 29 additions & 0 deletions Sources/OAuthKit/OAuthKit.docc/Extensions/Token.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# ``OAuthKit/OAuth/Token``

@Metadata {
@Available(iOS, introduced: "18.0")
@Available(macOS, introduced: "15.0")
@Available(tvOS, introduced: "18.0")
@Available(visionOS, introduced: "2.0")
@Available(watchOS, introduced: "11.0")
}

## Overview
A `Token` is the holder of an ``accessToken`` that can be used in an `URLRequest` to provide credentials for authentication, allowing access to protected resources.

```swift
/// Adds a header field of 'Authorization: Bearer <<access_token>>'
let value = "\(token.type) \(token.accessToken)"
var request: URLRequest = .init(url: url)
request.addValue(value, forHTTPHeaderField: "Authorization")
```

- SeeAlso:
[Access Token Response](https://www.oauth.com/oauth2-servers/access-tokens/access-token-response/)

## Topics

### Essentials

- ``OAuth/Authorization``
- ``Foundation/URLRequest/addAuthorization(auth:)``