Azure ADの認証をしたいだけなら、モバイルバックエンドは必要ありません.ADALライブラリとAzure ADのネイティブアプリケーションに適した構成です。まず
、ネイティブモバイルアプリ用のAzure ADを設定します。AzureのクラシックPortalに
- ログ(https://manage.windowsazure.com)
- すべての項目のリストから、適切なディレクトリを選択し
- クリックでアプリケーションタブ
- ページ下部の[追加]ボタンをクリックしてください
- 私の組織が開発中のアプリケーションを追加をクリックして
- は
- その後、タイプなどのネイティブクライアントアプリケーションを選択し
- が(それは何もすることができ、それが有効である必要があります)リダイレクトURIのための有効なURIを入力し、それに名前を付けたアプリケーションを作成するには、ダニをクリック。
この時点で、あなたはアプリを作成しました。 CONFIGUREタブをクリックし、クライアントIDとリダイレクトURIを書き留めます。
クライアントIDとADALライブラリのリダイレクトURIを置き換えることで、サンプルのいずれかを使用できるようになりました。サンプルの1つから関連するコードを次に示します。
- (void)acquireTokenInteractive:(id)sender
{
ADTestAppSettings* settings = [ADTestAppSettings settings];
NSString* authority = [settings authority];
NSString* resource = [settings resource];
NSString* clientId = [settings clientId];
NSURL* redirectUri = [settings redirectUri];
ADUserIdentifier* identifier = [self identifier];
ADCredentialsType credType = [self credType];
BOOL validateAuthority = _validateAuthority.selectedSegmentIndex == 0;
ADAuthenticationError* error = nil;
ADAuthenticationContext* context = [[ADAuthenticationContext alloc
initWithAuthority:authority
validateAuthority:validateAuthority
error:&error];
if (!context)
{
NSString* resultText = [NSString stringWithFormat:@"Failed to create AuthenticationContext:\n%@", error];
[_resultView setText:resultText];
return;
}
[context setCredentialsType:credType];
if ([self embeddedWebView])
{
[context setWebView:_webView];
//[_authView setFrame:self.view.frame];
[UIView animateWithDuration:0.5 animations:^{
[_acquireSettingsView setHidden:YES];
[_authView setHidden:NO];
}];
}
__block BOOL fBlockHit = NO;
[context acquireTokenWithResource:resource
clientId:clientId
redirectUri:redirectUri
promptBehavior:[self promptBehavior]
userIdentifier:identifier
extraQueryParameters:nil
completionBlock:^(ADAuthenticationResult *result)
{
if (fBlockHit)
{
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController* alert = [UIAlertController
alertControllerWithTitle:@"Error!"
message:@"Completion block was hit multiple times!"
preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alert animated:YES completion:nil];
});
return;
}
fBlockHit = YES;
dispatch_async(dispatch_get_main_queue(), ^{
[self updateResultView:result];
[_webView loadHTMLString:@"<html><head></head><body>done!</body></html>" baseURL:nil];
[_authView setHidden:YES];
[self.view setNeedsDisplay];
[[NSNotificationCenter defaultCenter] postNotificationName:ADTestAppCacheChangeNotification object:self];
});
}];
}
あなたを混乱させるすべての項目を更新してください。できるだけわかりやすいようにしてください。 –
アプリケーション自体へのアクセスを認証するか、認証されたIDをWebサービスに提供しますか? – Paulw11
ご意見ありがとうございます。投稿した質問は私が期待している最終結果です。混乱は、ここのモバイルサーバーが正確に何であるか? 1)私の最終結果を得るためにどのように実装することができますか? 2)上記の開始リンクは新しいiOSアプリの作成を示していますが、既に存在するアプリの実装方法を示しています。 3)ココアポッドでは、間違い/例外が増えているので、ココアポッドなしで他の選択肢はありません。 4)Azure ADのアプリケーションを作成しました(上のリンクを参照)。 –