AnsweredAssumed Answered

OAuth Complete - LocalHost Test

Question asked by Alexandre Schneider on Nov 5, 2018
Latest reply on Nov 11, 2018 by Kona Jones

Hi Community,

 

I'm new to this dev world and i'm amazed with all the possibilities that canvas has to offer to developers. But, before that, i need to learn how to authenticate my localhost website to use api calls, right? 

 

If i'm not going wrong, i need to work with Oauth login:

GET https://<canvas-install-url>/login/oauth2/auth?client_id=XXX&response_type=code&redirect_uri=urlRedirected&state=YYY

 

<form method="get" action="https://xxx.instructure.com/login/oauth2/auth?client_id=yyy&response_type=code&redirect_uri=https://example.com/oauth_complete">

  <input type="submit" value="submit">
</form>

 

So, lets say if i run this locally, inserting my client Id (that i generated on my canvas enviroment, developer key), this get call should work? (know that is not a good way of doing it, but just need to understand if this is a way to do it or not).

 

I'm receiving this:

while(1);{"error":"invalid_client","error_description":"unknown client"}

If this should work, what can be done to achieve it that i'm missing? (since it's returning this error message). 

 

If this should not work, where i can learn a little bit on how to authenticate a localhost webpage to canvas. 

 

Edit: I appended this html Get FORM to a actual page inside my canvas Application from the javascript theme insert and the result was the same. 

 

Edit2: Got it working!

 

Just used this:

<input type="button" name="getToken" value="Get Token" onclick="location.replace('https://<canvas_url>/login/oauth2/auth?client_id=id&amp;response_type=code&amp;redirect_uri=<uri_urL>&state=inv');">


Thanks for your support! 

 

Regards,

Alexandre "novice" Schneider

 

 

Outcomes