Skip to content

Instantly share code, notes, and snippets.

@ntakouris
Created August 29, 2019 09:08
Show Gist options
  • Save ntakouris/f5de047e5b59826c2f0aae2ab91626bd to your computer and use it in GitHub Desktop.
Save ntakouris/f5de047e5b59826c2f0aae2ab91626bd to your computer and use it in GitHub Desktop.
var cachedToken = string.Empty;
var identityApi = RestService.For<IIdentityApi>("https://localhost:5001");
var tweetbookApi = RestService.For<ITweetbookApi>("https://localhost:5001", new RefitSettings
{
AuthorizationHeaderValueGetter = () => Task.FromResult(cachedToken)
});
var registerResponse = await identityApi.RegisterAsync(new UserRegistrationRequest
{
Email = "[email protected]",
Password = "Test1234!"
});
var loginResponse = await identityApi.LoginAsync(new UserLoginRequest
{
Email = "[email protected]",
Password = "Test1234!"
});
cachedToken = loginResponse.Content.Token;
var allPosts = await tweetbookApi.GetAllAsync();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment