Fix refreshing credentials.
This commit is contained in:
parent
a373e03b2c
commit
e8d3787511
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue