Mobile App GetIdentityAsync no value

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 01:42:46

问题


I have this code from Azure Services Mobile App, API custom controller. The result always the same "1:1". I test with all identity providers, google, facebook, twitter, and Microsoft Account, except AD. I think the problem is the call to GetIdentityAsync. Can anyone help me? Thanks

    [HttpGet]
    public async Task<string> GetIdentityInfo()
    {
        var user = (MobileAppUser)this.User;            

        string str = "";
        string Provider = "YES", UserId = "NO";
        try
        {
            if (user != null)
            {
                Provider = "1"; UserId = "1";
                var microsoftCredentials = await user.GetIdentityAsync<MicrosoftAccountCredentials>();
                if (microsoftCredentials != null && microsoftCredentials.Claims != null)
                {
                    Provider = "MICROSOFT";
                    UserId = microsoftCredentials.UserId;
                }

                Provider = "2"; UserId = "2";
                var googleCredentials = await user.GetIdentityAsync<GoogleCredentials>();
                if (googleCredentials != null && googleCredentials.Claims != null)
                {
                    Provider = "GOOGLE";
                    UserId = googleCredentials.UserId;
                }

                Provider = "3"; UserId = "3";
                var facebookCredentials = await user.GetIdentityAsync<FacebookCredentials>();
                if (facebookCredentials != null && facebookCredentials.Claims != null)
                {
                    Provider = "FACEBOOK";
                    UserId = facebookCredentials.UserId;
                }

                Provider = "4"; UserId = "4";
                var twitterCredentials = await user.GetIdentityAsync<TwitterCredentials>();
                if (twitterCredentials != null && twitterCredentials.Claims != null)
                {
                    Provider = "TWITTER";
                    UserId = twitterCredentials.UserId;
                }
            }
            else
            {
                Provider = "NONE"; UserId = "NULL";
            }
        }
        catch (Exception ex)
        {
            str = "ERROR";
        }
        finally
        {
            str = Provider + ":" + UserId;
        }

        return str;
    }

回答1:


We receive support from Microsoft Support Engineer Adrian Fernandez Garcia, and send an example that worked OK. The unique difference was that EMA_RuntimeUrl must be created manually in mobile app in azure portal in Application Properties, and assigned to Gateway address.

Actually this value is created automatically and don't have to create it manually.

This gave us the error URIFormat NULL value.

All is working OK now.

Thanks to Microsoft for the support.



来源:https://stackoverflow.com/questions/32569643/mobile-app-getidentityasync-no-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!