AnsweredAssumed Answered

OAuth2 Authentication Request: "Route [login] not defined"?

Question asked by Lee Newton on Nov 8, 2019

Hi,

I'm developing a software that uses OAuth2 authentication with Canvas. It's to authenticate users, admins and non-users and see if they've permission to access a page. To that end, I'm following the documentation here:
https://canvas.instructure.com/doc/api/file.oauth.html
https://canvas.instructure.com/doc/api/file.oauth_endpoints.html#get-login-oauth2-auth

 

Per its instruction, I'm trying to GET from an endpoint, so my route is calling a request on:

GET https://<canvas-install-url>/login/oauth2/auth?client_id=XXX&response_type=code&redirect_uri=https://example.com/oauth_complete&state=YYY&scope=<value_1>%20<value_2>%20<value_n>

Which I've shortened down to this:

https://my.test.instructure.com/login/oauth2/auth?client_id=9&response_type=code&redirect_uri=http://www.google.com


However, when I try to make a request on this route, I get the following error message:

Symfony\Component\Routing\Exception\RouteNotFoundException: Route [login] not defined.

It seems it doesn't like the "login" part? I don't understand why. Could anyone please offer some clarity on the subject? I'd be most grateful.

 

If it's of any use, here is my code in laravel for the route request:

 

Route::get('/testClient', ['as' => 'testClient', 'uses' => function(Request $request) {
   $http = new GuzzleHttp\Client;
   $response = $http->post('https://my.test.instructure.com/login/oauth2/auth?client_id=9&response_type=code&redirect_uri=http://www.google.com', [
      'form_params' => [
         'grant_type' => 'authorization_code',
         'client_id' => my_id,
         'client_secret' => 'my_secret',
         'redirect_uri' => 'www.google.com',
      ],
   ]);

   return json_decode((string) $response->getBody(), true)['access_token'];
}])->middleware('client');

 

EDIT: This was an error on Laravel's end, not on Canvas'. It was because my middleware routes in there were not configured correctly. This problem for me has now been solved.

Outcomes