AppAuth - окно внешнего браузера не открывается? - PullRequest
1 голос
/ 05 апреля 2019

Я использую библиотеку AppAuth для индивидуального единого входа в мое приложение, написанное в задаче c.

До сих пор мне удалось заставить его работать быстро, но когда я использую тот же код, преобразованный в цель c, браузер не открывается. Это то, что я до сих пор (удалил все URL и идентификаторы из кода, включенного здесь, так что не забывайте, что строки здесь пусты):

В приложении делегат:

@property(nonatomic, strong, nullable) id<OIDExternalUserAgentSession> currentAuthorizationFlow;

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *, id> *)options {
// Sends the URL to the current authorization flow (if any) which will process it if it relates to
// an authorization response.
if ([_currentAuthorizationFlow resumeExternalUserAgentFlowWithURL:url]) {
    _currentAuthorizationFlow = nil;
    return YES;
}

return NO;
}

А в viewcontroller:

- (IBAction)loginButtonAction:(id)sender {
NSURL *authorizationEndpoint = [NSURL URLWithString:@""];
NSURL *tokenEndpoint = [NSURL URLWithString:@""];

OIDServiceConfiguration *configuration = [[OIDServiceConfiguration alloc] initWithAuthorizationEndpoint:authorizationEndpoint tokenEndpoint:tokenEndpoint];

NSString *clientId = @"";
NSURL *redirectUri = [NSURL URLWithString:@""];

OIDAuthorizationRequest *builder = [[OIDAuthorizationRequest alloc] initWithConfiguration:configuration clientId:clientId scopes:@[OIDScopeOpenID] redirectURL:redirectUri responseType:OIDResponseTypeCode additionalParameters:nil];

// performs authentication request
AppDelegate *appDelegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
appDelegate.currentAuthorizationFlow = [OIDAuthState authStateByPresentingAuthorizationRequest:builder presentingViewController:self callback:^(OIDAuthState *_Nullable authState, NSError *_Nullable error) {
    if (authState) {
        NSLog(@"Got authorization tokens. Access token: %@", authState.lastTokenResponse.accessToken);
    } else {
        NSLog(@"Authorization error: %@", [error localizedDescription]);
    }
}];
}

Это открывает предупреждение, спрашивающее пользователя, хочет ли он / она войти в систему, и если я нажимаю продолжить, должен открыться внешний браузер с пользовательской страницей единого входа. Проблема в том, что ничего не происходит после нажатия кнопки «Продолжить».

Есть идеи?

1 Ответ

0 голосов
/ 25 июня 2019

Проверьте параметры в вашей конфигурации и запрос, в частности, эмитента.Не сохраняя currentAuthorizationFlow также остановил мой поток мертвым.

hth.

...