File tree Expand file tree Collapse file tree
contentstack.model.generator.tests
contentstack.model.generator/CMA/OAuth Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55using contentstack . CMA ;
66using contentstack . CMA . OAuth ;
77using System . Net . Http ;
8- using Newtonsoft . Json ;
98using System . Collections . Generic ;
109
1110namespace contentstack . model . generator . tests
Original file line number Diff line number Diff line change 11using System ;
2+ using System . Text . Json ;
23using contentstack . CMA . OAuth ;
34using Xunit ;
45
@@ -61,8 +62,9 @@ public void OAuthTokenResponse_ShouldBeSerializable()
6162 } ;
6263
6364
64- var json = Newtonsoft . Json . JsonConvert . SerializeObject ( response ) ;
65- var deserializedResponse = Newtonsoft . Json . JsonConvert . DeserializeObject < OAuthTokenResponse > ( json ) ;
65+ var json = JsonSerializer . Serialize ( response ) ;
66+ var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true } ;
67+ var deserializedResponse = JsonSerializer . Deserialize < OAuthTokenResponse > ( json , options ) ;
6668
6769
6870 Assert . NotNull ( deserializedResponse ) ;
Original file line number Diff line number Diff line change 44using System . Security . Cryptography ;
55using System . Text ;
66using System . Threading . Tasks ;
7- using Newtonsoft . Json ;
7+ using System . Text . Json ;
88using System . Text . Json . Serialization ;
99
1010namespace contentstack . CMA . OAuth
@@ -171,14 +171,15 @@ public static async Task<OAuthTokenResponse> ExchangeCodeForTokenAsync(Contentst
171171
172172 // Parse response
173173 string responseContent = await response . Content . ReadAsStringAsync ( ) ;
174- var tokenResponse = JsonConvert . DeserializeObject < OAuthTokenResponse > ( responseContent ) ;
175-
174+ var serializerOptions = new JsonSerializerOptions { PropertyNameCaseInsensitive = true } ;
175+ var tokenResponse = JsonSerializer . Deserialize < OAuthTokenResponse > ( responseContent , serializerOptions ) ;
176+
176177 // Set expiration time if not already set
177178 if ( tokenResponse . ExpiresAt == default ( DateTime ) && tokenResponse . ExpiresIn > 0 )
178179 {
179180 tokenResponse . ExpiresAt = DateTime . UtcNow . AddSeconds ( tokenResponse . ExpiresIn ) ;
180181 }
181-
182+
182183 return tokenResponse ;
183184 }
184185 }
@@ -231,8 +232,9 @@ public static async Task<OAuthTokenResponse> RefreshTokenAsync(ContentstackOptio
231232
232233 // Parse response
233234 string responseContent = await response . Content . ReadAsStringAsync ( ) ;
234- var tokenResponse = JsonConvert . DeserializeObject < OAuthTokenResponse > ( responseContent ) ;
235-
235+ var serializerOptions = new JsonSerializerOptions { PropertyNameCaseInsensitive = true } ;
236+ var tokenResponse = JsonSerializer . Deserialize < OAuthTokenResponse > ( responseContent , serializerOptions ) ;
237+
236238 // Set expiration time if not already set
237239 if ( tokenResponse . ExpiresAt == default ( DateTime ) && tokenResponse . ExpiresIn > 0 )
238240 {
You can’t perform that action at this time.
0 commit comments