-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
I am trying to get this working but I am not having luck with the code part. It opens a safari page, it authenticates, then takes me to my redirect uri. However, it doesnt do any after that. It doesnt finish the task.
This is the code I have
import Foundation
import AAA
import ComposableArchitecture
@MainActor
public final class ATOauth {
let debounceDuration: DispatchQueue.SchedulerTimeType.Stride = 0.1
let prefersEphemeralWebBrowserSession = false
let mainQueue = DispatchQueue.main
typealias Reducer = AAAFlowReducer<ATOauthMiddleware>
typealias State = Reducer.State
public init(){}
public func login(environment: ATOauthMiddleware.Environment, redirectUri: URL, identityProvider: String) async throws -> ATOauthMiddleware.Credentials? {
let authCode = ATOauthMiddleware.authCode(scope: nil, environment: environment, redirectUri: redirectUri, identityProvider: identityProvider)
let store = Store(initialState: State.init(authFlow: authCode, prefersEphemeralWebBrowserSession: prefersEphemeralWebBrowserSession, debounceDuration: debounceDuration)) {
Reducer()
} withDependencies: { [self] in
$0.mainQueue = mainQueue.eraseToAnyScheduler()
}
await store.send(.auth).finish()
let response: ATOauthMiddleware.TokenUrl.Response? = store.withState { state in
guard let accessTokenResponse = state.accessTokenResponse else {
return nil
}
return accessTokenResponse
}
guard let response = response else {
return nil
}
return ATOauthMiddleware.Credentials(accessToken: response.access_token, expiresIn: response.expires_in, refreshToken: response.refresh_token, scope: response.scope, tokenType: response.token_type)
}
I also just tried thee reducer test just to see if the code prints but it doesnt get past await store.send(.asyncCall(authFlow.authorizationUrlParameter(prefersEphemeralWebBrowserSession: prefersEphemeralWebBrowserSession)!)).finish()
Metadata
Metadata
Assignees
Labels
No labels