I have an Application that I am using MVC to facilitate the OAuth 2 interfacing with a 3rd party. What I am currently doing in my MVC Controller is
public async Task<IActionResult> Index()
{
string urlToRedirect = _client.GetUrl();
return View((object)urlToRedirect);
}
From there, I have a link on the page that uses the URL to redirect to navigate to the page (auth page of provider). I then I have another Action on my controller that does this
public async Task<IActionResult> Auth()
{
if (System.Web.HttpUtility.ParseQueryString(Request.QueryString.Value)?.Count > 0)
{
string accessToken = _client.GetAccessToken(System.Web.HttpUtility.ParseQueryString(Request.QueryString.Value));
return return View((object)accessToken);
}
}
Access Token is the token that will be used to make subsequent API calls. The plan is to send this token to my WebApi and then make a call to the provider to get data, modify and send back to the client.
I want to be able to get access to the token in Vue.js from the Model and use it to make calls to my Web API which will call the provider, modify data and send back to the client. I am using JavascriptServices for reference, but I am not quite sure where I would put the code in Vue.js to get the model. Is this the right way of doing this?