I have been trying to authenticate users using the GitHub API Im using .net core as my app and the first part of the authentication works fine and redirects to my app but when I try to exchange the temporary code for a token I always get invalid credentials
So, in your example “grant_type”, “redirect_uri” and “state” values are missing (state is passed as redirect query parameter). Also, I would recommend to enable logging and check that all values that you send are correct.
This is interesting. So I was keeping it dead simple, only using the required fields, The first stage seems to work but the second stage seems to throw that invalid credentials error. Im using the Web Application flow guide from github. I tried logging it and it all seems fine…
It says that invalid client credentials error is reported when client id or secret are not valid.
I am not familiar with .net APIs, but would suggest to check also Content-Type request header value you set for the token request. In our code it is set to “application/x-www-form-urlencoded”, also Accept header is set to “application/json”