Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetACSToken() method return (400) Bad Request #149

Open
alexchen2016 opened this issue Jun 13, 2016 · 0 comments
Open

GetACSToken() method return (400) Bad Request #149

alexchen2016 opened this issue Jun 13, 2016 · 0 comments

Comments

@alexchen2016
Copy link

I test the code from https://github.com/Azure/azure-sdk-for-media-services/blob/dev/samples/MediaServicesRESTSample/RESTAPISamples/RESTAPISamples/Program.cs, I get error An unhandled exception of type 'System.Net.WebException' occurred in System.dll.Additional information: The remote server returned an error: (400) Bad Request. when running the code below:

 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(accessControlUri);
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.KeepAlive = true;
            string token = null;

            //Note: You need to insert your client Id and secret into this string in order for it to work.
            var requestBytes = Encoding.ASCII.GetBytes("grant_type=client_credentials&client_id=" + clientId + "&client_secret=" + HttpUtility.UrlEncode(clientSecret) + "&scope=urn%3a" + scope);
            request.ContentLength = requestBytes.Length;

            // Write the request data to the request stream
            var requestStream = request.GetRequestStream();
            requestStream.Write(requestBytes, 0, requestBytes.Length);
            requestStream.Close();

            // Get the response back from the server
            var response = (HttpWebResponse)request.GetResponse();

Thank you for reviewing my issue. Any help will be welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant