Hello (sorry for my bad english)
I have an Angular Vue.js front that connect to my Rest Api Services in C# . I have at least 20 services developed. Now I want to secure them.
With POSTMAN and the url https://login.microsoftonline.com ... I get the "Token" , then I try to get the authorization and I put hardCode the given token , and the result its: "StatusCode": 200, "ReasonPhrase": "Authorized",
I do something like this:
public class TokenController : ApiController
{
public IHttpActionResult Get()
{
Task<HttpResponseMessage> d = TokenManager.GetGroups("token");
return Ok(d);
}
}
public static Task<HttpResponseMessage> GetGroups(string token)
{
var httpClient = new HttpClient();
var uri = "https://graph.microsoft.com/v1.0/groups";
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var res = httpClient.GetAsync(uri, HttpCompletionOption.ResponseContentRead).Result;
return Task.Delay(3000).ContinueWith(t => res);
}
My problem its that I don´t know where or what I have to do to Get the "Bearer Token" from the "Front". I can't get the token by parameter in the URL of the service because is to long.
Thank you.
With Request.Headers I have the Bearer Token.
I call "string tt = Request.Headers.Authorization.ToString();" in my controller and it works fine
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.