Guest User

Untitled

a guest
Apr 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. # Load the plugin in the startup() method of Mojolicious application class
  2.  
  3. ```perl
  4. sub startup {
  5. my $self = shift;
  6.  
  7. ...
  8.  
  9. $self->plugin( 'OAuth2::Server' => $oauth2_auth_code_grant_config );
  10. }
  11. ```
  12.  
  13. # Add a route for getting userinfo
  14.  
  15. ```perl
  16. $routes->add(under '/api' => sub {
  17. 20 my ($c) = @_;
  18. 21
  19. 22 return 1 if $c->oauth; # must be authorized via oauth
  20. 23
  21. 24 $c->render( status => 401, text => 'Unauthorized' );
  22. 25 return undef;
  23. 26 };
Add Comment
Please, Sign In to add comment