Showing results for 
Show  only  | Search instead for 
Did you mean: 
Community Participant

Suddenly stopped receiving access token in OAuth 2.0 flow in Canvas LMS

I have an LTI plug-in which has been using OAuth 2.0 to authenticate/authorize. The tool has been working fine for 1 year but yesterday I faced a problem.

I am unable to get access token and hence the tool stopped working.

In summary, I use a GET request to get access code as below: 


Once I received code in the redirect Uri, I make a post request to get an access token. But I am not receiving access token now and my C# code is posted with the question. Could you please help me?


string json = string.Empty;
string urlCommand = "/login/oauth2/token";

using (HttpClient client = new HttpClient())
client.Timeout = TimeSpan.FromHours(1);
string url = "";

client.BaseAddress = new Uri(url);

Dictionary<string, string> vars = new Dictionary<string, string>();
vars.Add("grant_type", "authorization_code"); //value will be either 'authorization_code' or 'refresh_token'
vars.Add("client_id", "10000000000011"); //this is the developer key "ID" value
vars.Add("client_secret", "nT2Icq7eSEQAFj6wqYE31F5iNgpi1gK2J7WC5Y6BN8c06pvroYRm2rwDkk2XuhM9"); //this is the developer key "Key" value
vars.Add("redirect_uri", "https://localhost:44399/Home/oauth2Response?code=" + code + "&state=1234"); //this is the developer key "URI" value

if (!string.IsNullOrEmpty(code)) vars.Add("code", code); //if canvas gave us a code, send it

string varString = JsonConvert.SerializeObject(vars);
HttpContent httpContent = new FormUrlEncodedContent(vars.ToArray());

using (HttpResponseMessage response = await client.PostAsync(urlCommand, httpContent))
if (response.IsSuccessStatusCode)
// excellent, canvas returned a success code, we should have also received token data, let's store the token data
json = await response.Content.ReadAsStringAsync();

ViewBag.accessToken = json;


catch (Exception ex)



0 Kudos
0 Replies