add scope in request token in C#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Plan
Premium
Country
France
Hi, I'm trying to get the token but I need some scope to be added , this code works for any other request that don't require scope...
Can you point me in the right direction please ... 😃
public string GetAccessToken()
{ string url5 = "https://accounts.spotify.com/api/token";
var clientid = " my client id here ";
var clientsecret = " client secret ";
var encode_clientid_clientsecret = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", clientid, clientsecret)));
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url5); webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.Accept = "application/json"; webRequest.Headers.Add("Authorization: Basic " + encode_clientid_clientsecret); var request = ("grant_type=client_credentials"); byte[] req_bytes = Encoding.ASCII.GetBytes(request);
webRequest.ContentLength = req_bytes.Length; Stream strm = webRequest.GetRequestStream();
strm.Write(req_bytes, 0, req_bytes.Length);
strm.Close();
HttpWebResponse resp = (HttpWebResponse)webRequest.GetResponse();
String json = "";
using (Stream respStr = resp.GetResponseStream()) {
using (StreamReader rdr = new StreamReader(respStr, Encoding.UTF8)) {
json = rdr.ReadToEnd();
rdr.Close(); } }
return json;
Labels:
- Labels:
-
access token scope Csharp
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page