Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Load the plugin in the startup() method of Mojolicious application class
- ```perl
- sub startup {
- my $self = shift;
- ...
- $self->plugin( 'OAuth2::Server' => $oauth2_auth_code_grant_config );
- }
- ```
- # Add a route for getting userinfo
- ```perl
- $routes->add(under '/api' => sub {
- 20 my ($c) = @_;
- 21
- 22 return 1 if $c->oauth; # must be authorized via oauth
- 23
- 24 $c->render( status => 401, text => 'Unauthorized' );
- 25 return undef;
- 26 };
Add Comment
Please, Sign In to add comment