Fix refreshing credentials.

This commit is contained in:
Marcin Czachursk 2023-02-09 18:17:01 +01:00
parent a373e03b2c
commit e8d3787511
2 changed files with 7 additions and 5 deletions

View File

@ -32,9 +32,9 @@ public class Application: BaseApplication {
case vapidKey = "vapid_key"
}
public init(clientId: String, clientSecret: String, vapidKey: String = "") {
public init(clientId: String, clientSecret: String, redirectUri: String, vapidKey: String = "") {
self.id = ""
self.redirectUri = "urn:ietf:wg:oauth:2.0:oob"
self.redirectUri = redirectUri
self.clientId = clientId
self.clientSecret = clientSecret
self.vapidKey = vapidKey

View File

@ -169,15 +169,17 @@ public class AuthorizationService {
let client = MastodonClient(baseURL: accountData.serverUrl)
// Create application (we will get clientId amd clientSecret).
let oAuthApp = Application(clientId: accountData.clientId, clientSecret: accountData.clientSecret)
// Create application (we will get clientId and clientSecret).
let oAuthApp = Application(clientId: accountData.clientId,
clientSecret: accountData.clientSecret,
redirectUri: AppConstants.oauthRedirectUri)
// Authorize a user (browser, we will get clientCode).
let oAuthSwiftCredential = try await client.authenticate(app: oAuthApp,
scope: Scopes(AppConstants.oauthScopes),
callbackUrlScheme: AppConstants.oauthScheme,
presentationContextProvider: presentationContextProvider)
// Get authenticated client.
let authenticatedClient = client.getAuthenticated(token: oAuthSwiftCredential.oauthToken)