public static async Task <UserInfoResponseData> GetUserInfoAsync(Configuration config, MASDevice device, MASUser user) { var url = config.GetEndpointPath(config.OAuth.ProjectedEndpoints.UserInfo); var accessTokenHeaderValue = await user.GetAccessHeaderValueAsync(); var headers = new Dictionary <string, string> { { HttpHeaders.Authorization, accessTokenHeaderValue }, { "mag-identifier", device.MagId }, { HttpHeaders.Accept, HttpContentTypes.Json } }; return(await HttpRequestFactory.RequestAsync <UserInfoResponseData>(new HttpRequestInfo() { Url = url, Method = HttpMethod.GET, Headers = headers })); }
public static async Task <RegisterResponseData> RegisterDeviceAsync(Configuration config, MASDevice device, string csr) { var url = config.GetEndpointPath(config.Mag.SystemEndpoints.DeviceClientRegister); var headers = new Dictionary <string, string> { { "client-authorization", device.AuthHeaderValue }, { "device-id", device.Id.ToBase64() }, { "device-name", device.Name.ToBase64() }, { "cert-format", "base64" }, { HttpHeaders.ContentType, HttpContentTypes.Plain }, { HttpHeaders.Accept, HttpContentTypes.Plain } }; return(await HttpRequestFactory.RequestAsync <RegisterResponseData>(new HttpRequestInfo() { Method = HttpMethod.POST, Url = url, Headers = headers, Body = csr })); }
public static async Task RevokeAccessTokenAsync(Configuration config, MASDevice device, MASUser user) { var url = config.GetEndpointPath(config.OAuth.SystemEndpoints.TokenRevocation); var accessToken = await user.GetAccessTokenAsync(); HttpUrlBuilder builder = new HttpUrlBuilder(url); builder.Add("token", accessToken); builder.Add("token_type_hint", "access_token"); var headers = new Dictionary <string, string> { { HttpHeaders.Authorization, device.AuthHeaderValue }, { HttpHeaders.Accept, HttpContentTypes.Json } }; await HttpRequestFactory.RequestAsync <HttpResponseBaseData>(new HttpRequestInfo() { Method = HttpMethod.DELETE, Headers = headers, Url = builder.ToString(), }); }