Beispiel #1
0
        public static async Task <ClientCredentialsResponseData> GetClientCredentialsAsync(Configuration config, string deviceIdBase64)
        {
            var url = config.GetEndpointPath(config.Mag.SystemEndpoints.ClientCredentialInit);

            var clientId = config.OAuth.Client.ClientIds[0];

            var builder = new HttpUrlBuilder();

            builder.Add("client_id", clientId.Id);
            builder.AddNonce();

            var headers = new Dictionary <string, string>
            {
                { HttpHeaders.Authorization, clientId.BasicAuthValue },
                { "device-id", deviceIdBase64 },
                { HttpHeaders.ContentType, HttpContentTypes.UrlEncoded },
                { HttpHeaders.Accept, HttpContentTypes.Json }
            };

            return(await HttpRequestFactory.RequestAsync <ClientCredentialsResponseData>(new HttpRequestInfo()
            {
                Method = HttpMethod.POST,
                Url = url,
                Headers = headers,
                Body = builder.ToString()
            }));
        }