public void GetAccessToken(AccessToken token, string basic) { try { var param = new List <OkHttpUtils.Param>() { new OkHttpUtils.Param("grant_type", "client_credentials") }; OkHttpUtils.Instance(token).Post(ApiUtils.Token, basic, param, async(call, response) => { var code = response.Code(); var body = await response.Body().StringAsync(); if (code == (int)System.Net.HttpStatusCode.OK) { token = JsonConvert.DeserializeObject <AccessToken>(body); token.RefreshTime = DateTime.Now; TokenShared.Update(context, token); } else { TokenShared.Update(context, new AccessToken()); } }, (call, ex) => { }); } catch (Exception ex) { } }
public void GetAccessTokenSuccess(AccessToken token) { TokenShared.Update(this, token); StartMain(); }