38 lines
1.1 KiB
Swift
38 lines
1.1 KiB
Swift
//
|
|
// MastodonController.swift
|
|
// Tusker
|
|
//
|
|
// Created by Shadowfacts on 8/15/18.
|
|
// Copyright © 2018 Shadowfacts. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import MastodonKit
|
|
|
|
struct MastodonController {
|
|
|
|
static private(set) var shared = MastodonController()
|
|
|
|
var client: Client!
|
|
|
|
private init() {
|
|
}
|
|
|
|
mutating func connect() {
|
|
// TODO: OAuth
|
|
let url = ProcessInfo.processInfo.environment["mastodon_url"]!
|
|
let username = ProcessInfo.processInfo.environment["mastodon_username"]!
|
|
let password = ProcessInfo.processInfo.environment["mastodon_password"]!
|
|
|
|
client = Client(baseURL: url)
|
|
|
|
let loginReq = Login.silent(clientID: "net.shadowfacts.Tusker", clientSecret: "some super secret thing", scopes: [.read, .write, .follow], username: username, password: password)
|
|
|
|
client.run(loginReq) { result in
|
|
guard case let .success(loginSettings, _) = result else { fatalError() }
|
|
print("access token: \(loginSettings.accessToken)")
|
|
}
|
|
}
|
|
|
|
}
|