0

This is my first time working with an API needing auth. I've went through all the different nuget packages available. I would like to build a console app where I can parse the JSON results like I do with my other API console apps.

Is this even possible for spotify or do I absolutely need a redirect to spotify log in?

I've been researching this issue for over a week now.

How I would like to code the endpoints if I had authorization working:

var url = "https://example.com/endpoint";

var request = WebRequest.Create(url);
request.Method = "GET";

var webResponse = request.GetResponse();
var webStream = webResponse.GetResponseStream();

var reader = new StreamReader(webStream);
var data = reader.ReadToEnd();

Console.WriteLine(data);

Foo bar = JsonConvert.DeserializeObject<Foo>(data);

class Foo 
{
    public double Jsonobject { get; set; }

    public string Jsonobject { get; set; }

    public float Jsonobject { get; set; }
}
RBT
  • 24,161
  • 21
  • 159
  • 240
  • What're you trying to achieve here? Build a console app, and login into Spotify with your console app? – Xiang Wei Huang May 11 '22 at 04:25
  • @XiangWeiHuang I just want to get the Json data from a endpoint displayed in a console app. The issue is getting past Authentication. – Brandon Noel May 11 '22 at 04:32
  • 1
    Then the issue is authentication. Spotify is using OAuth, you should look into how to implement OAuth in C#, like how to put the token into your request header, for the API to validate with. [This SO post might help](https://stackoverflow.com/questions/38494279/how-do-i-get-an-oauth-2-0-authentication-token-in-c-sharp). – Xiang Wei Huang May 11 '22 at 08:29
  • 1
    Yea I definitely need to look at a few things. I was hoping to just use a nuget package to solve my problems. I'm going back to the basics to refresh myself on objects and classes so I can read other peoples code more effectively, and to touch up on a nasty habit I've developed with my own coding. From there gonna deep dive on Restful api calls. I read through that post and I will refer to it again when I'm ready. Thanks! – Brandon Noel May 12 '22 at 01:58

0 Answers0