Kotori
A super lightweight and testable library for Twitter written in Swift using Combine and async/await
Statuses
Futures
- [x] Support Twitter v1 API (OAuth1.0)
- [x] Login with Twitter
- [x] Multiple accounts management
- [x] Support making an authorized
URLRequest
- [x] Support chunked media upload
- [ ] Support Twitter v2 API (OAuth2.0)
Installation
Use swift package manager.
Usage
Login with Twitter
Use ClientCredential
, TwitterAuthorizationFlow
and TwitterAccountStore
.
- Prepare for login.
- Authorization handshake start.
- Open the Twitter login page in your app.
Kotori request you for open the twitter login page to authorize by the user.
So, add codes which open the twitter login page in your app.
- Open your app from the Twitter login page. (URL Scheme)
After finished login in the Twitter login page, The Twitter login page redirects to the your app using url scheme including credential parameters.
So, add codes which handle the url scheme and pass it to the Kotori.
- Handle login completion callback from the Kotori.
After call this, twitterLoginFlow.authorize().sink()
will be called.
Account management
Use TwitterAccountStore
.
let accountStore = TwitterAccountStore(keychainAccessGroup: "your keychain access group")
accountStore.allCredentials()
API call
Use TwitterAPIRequest
.
Kotori does not provide the network layer, response parser. Just only URLRequest.
Media upload
Use TwitterMediaUploader
.
Kotori supports chunked upload. Chuneked upload is a very fast upload method but has many steps and difficult. So, Kotori may help you.
Single image upload sample.
Multiple image upload sample.
Contribution
PRs are welcome. Format is free!
Naming
Kotori is small bird
in Japanese.
Kotori is small and lightweight library for the Twitter.