diff --git a/Sources/OAuthKit/OAuth+Token.swift b/Sources/OAuthKit/OAuth+Token.swift index 7267d77..2ba873a 100644 --- a/Sources/OAuthKit/OAuth+Token.swift +++ b/Sources/OAuthKit/OAuth+Token.swift @@ -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. diff --git a/Sources/OAuthKit/OAuthKit.docc/Extensions/Authorization.md b/Sources/OAuthKit/OAuthKit.docc/Extensions/Authorization.md new file mode 100644 index 0000000..acca32e --- /dev/null +++ b/Sources/OAuthKit/OAuthKit.docc/Extensions/Authorization.md @@ -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:)`` diff --git a/Sources/OAuthKit/OAuthKit.docc/Extensions/Token.md b/Sources/OAuthKit/OAuthKit.docc/Extensions/Token.md new file mode 100644 index 0000000..63d1b54 --- /dev/null +++ b/Sources/OAuthKit/OAuthKit.docc/Extensions/Token.md @@ -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 <>' +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:)``