public void APITestRefreshTokenOk() { var json = @" { ""access_token"": ""abc123"", ""expires_in"": 12345, ""id_token"": ""abcdefg"", ""refresh_token"": ""abc321"", ""scope"":""profile openid"", ""token_type"": ""Bearer"" } "; var called = false; LineAPI.RefreshAccessToken(result => { Assert.True(result.IsSuccess); result.MatchOk(token => { called = true; Assert.AreEqual("abc123", token.Value); Assert.AreEqual(12345, token.ExpiresIn); Assert.AreEqual("abcdefg", token.IdTokenRaw); Assert.AreEqual("abc321", token.RefreshToken); Assert.AreEqual("profile openid", token.Scope); Assert.AreEqual("Bearer", token.TokenType); }); }); var identifier = LineAPI.actions.Keys.ToList()[0]; LineAPI._OnApiOk(CallbackPayload.WrapValue(identifier, json)); Assert.True(called); Assert.IsEmpty(LineAPI.actions); }
public void APITestRefreshTokenError() { var json = @" { ""code"": 123, ""message"": ""error"" } "; var called = false; LineAPI.RefreshAccessToken(result => { Assert.True(result.IsFailure); result.MatchError(error => { called = true; Assert.AreEqual(123, error.Code); Assert.AreEqual("error", error.Message); }); }); var identifier = LineAPI.actions.Keys.ToList()[0]; LineAPI._OnApiError(CallbackPayload.WrapValue(identifier, json)); Assert.True(called); Assert.IsEmpty(LineAPI.actions); }
public void RefreshToken() { LineAPI.RefreshAccessToken(result => { result.Match( value => { UpdateRawSection(value); }, error => { UpdateRawSection(error); } ); }); }