アズール、ログイン成功のコード結果のこのセクションのストリームによると:Azure App Servicesでは、(App Service認証サービスを使用して)正常にログオンした後にテーブルにアクセスできないのはなぜですか?
MobileServiceUser user = null;
private async System.Threading.Tasks.Task<bool> AuthenticateAsync()
{
string message;
bool success = false;
var provider = MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory;
// Use the PasswordVault to securely store and access credentials.
PasswordVault vault = new PasswordVault();
PasswordCredential credential = null;
try
{
// Try to get an existing credential from the vault.
credential = vault.FindAllByResource(provider.ToString()).FirstOrDefault();
}
catch (Exception)
{
// When there is no matching resource an error occurs, which we ignore.
}
if (credential != null)
{
// Create a user from the stored credentials.
user = new MobileServiceUser(credential.UserName);
credential.RetrievePassword();
user.MobileServiceAuthenticationToken = credential.Password;
// Set the user from the stored credentials.
App.MobileService.CurrentUser = user;
// Consider adding a check to determine if the token is
// expired, as shown in this post: http://aka.ms/jww5vp.
success = true;
message = string.Format("Cached credentials for user - {0}", user.UserId);
}
else
{
try
{
// Login with the identity provider.
user = await App.MobileService
.LoginAsync(provider, true);
// Create and store the user credentials.
credential = new PasswordCredential(provider.ToString(),
user.UserId, user.MobileServiceAuthenticationToken);
vault.Add(credential);
success = true;
message = string.Format("You are now logged in - {0}", user.UserId);
}
catch (MobileServiceInvalidOperationException)
{
message = "You must log in. Login Required";
}
}
var dialog = new MessageDialog(message);
dialog.Commands.Add(new UICommand("OK"));
await dialog.ShowAsync();
return success;
}
しかし、私はIServiceTableからの情報をつかむしようとすると、アクセスが拒否されます。 Azureのストリームでは、テーブルへのアクセスに使用されるログオンメソッドが「匿名」であることに気付きました。誰も助けることができますか?
ありがとうございました。私はあなたのアドバイスを取って、トークンキャッシングを制御する行をコメントアウトしました。残念ながら、Postmanを介してリクエストでトークンを手動で送信しても、私はまだアクセスが拒否されます。私は成功したログオンページにリダイレクトされます。私のエラーはAzureのリダイレクトURIやその他の設定のエントリによって発生する可能性がありますか?私はそれらをチェックして再点検したが、私は何かを理解していないかもしれない。ご協力いただきありがとうございます! – Matt
郵便配達員の場合は、 'https:// {your-app-name} .azurewebsites.net/tables/{テーブル名}'を取得し、** x-zumo-auth **ヘッダーに値を設定して追加することができます'authenticationToken'です。さらに、他のログインプロバイダ(MSA、Facebookなど)を設定してから、 'https:// {your-app-name} .azurewebsites.net/.auth/login/{microsoftaccount | facebookブラウザから 'https:// {your-app-name} .azurewebsites.net/tables/{table-name}'にアクセスしてモバイルサーバー側にアクセスできることを確認してから、モバイルクライアントコード。 –