刷新失败,并显示403禁止错误。刷新令牌已撤消或过期

时间:2018-10-03 10:26:41

标签: c# xamarin.android azure-mobile-services google-authentication refresh-token

我正在使用Microsoft.WindowsAzure.MobileServices.MobileServiceClient对其用户的Google帐户进行身份验证,并使用Xamarin.Auth.AccountStore来存储令牌。当应用程序首次运行时,AccountStore为空。用户使用MobileServiceClient.LoginAsync方法登录。

    client.LoginAsync(_mainActivity, 
 MobileServiceAuthenticationProvider.Google, "myjobdiary", new Dictionary<string, string>
            {
                { "access_type", "offline" }
            });

一切正常,授权用户并使用方法存储令牌。

        public void StoreTokenInSecureStore(MobileServiceUser user)
    {
        var account = new Account(user.UserId);
        account.Properties.Add("token", user.MobileServiceAuthenticationToken);
        _accountStore.Save(account, "myjobdiary");
    }

现在,我重新启动我的应用,并使用方法从帐户存储中恢复用户。

        public MobileServiceUser RetrieveTokenFromSecureStore()
    {
        var accounts = _accountStore.FindAccountsForService("myjobdiary");
        if (accounts != null)
        {
            foreach (var acct in accounts)
            {
                if (acct.Properties.TryGetValue("token", out string token))
                {
                    return new MobileServiceUser(acct.Username)
                    {
                        MobileServiceAuthenticationToken = token
                    };
                }
            }
        }
        return null;
    }

已检索的用户设置为使用过的MobileServiceClient。现在,我想使用MobileServiceClient.RefreshUserAsync方法刷新令牌。异常'刷新失败,出现403禁止错误。刷新令牌已撤消或过期。”发生了。 mobile apps with azure, refresh tokens

1 个答案:

答案 0 :(得分:0)

double binSize = 50;
double[] binArray = new double[someNumberOfBins]
double[] summedIntensities= new double[numberOfTheirSummedIntensities];
for(i=0; i<twoDimensionalArray.GetLength(1); i++){
    double currentMass= twoDimensionalArray[0,i];
    for(j=0; j<binArray.GetLength(1); j++) {
        if(currentMass> (binArray[j] - binSize) && currentMass <= (binArray[j] + binSize)) {
            double currentIntensity = twoDimensionalArray[1,i];
            summedIntensities[j] += currentIntensity;
         }
    }
//somehow combine the binArray with summedIntensities array into a two dimensional array