File tree Expand file tree Collapse file tree 5 files changed +20
-5
lines changed
groovy/io/vertx/example/web/oauth2
java/io/vertx/example/web/oauth2
js/io/vertx/example/web/oauth2
kotlin/io/vertx/example/web/oauth2
ruby/io/vertx/example/web/oauth2 Expand file tree Collapse file tree 5 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ router.get("/").handler({ ctx ->
39
39
// The protected resource
40
40
router. get(" /protected" ). handler({ ctx ->
41
41
def user = ctx. user()
42
-
42
+ // retrieve the user profile, this is a common feature but not from the official OAuth2 spec
43
43
user. userInfo({ res ->
44
44
if (res. failed()) {
45
45
// request didn't succeed because the token was revoked so we
@@ -52,6 +52,9 @@ router.get("/protected").handler({ ctx ->
52
52
def userInfo = res. result()
53
53
54
54
// fetch the user emails from the github API
55
+
56
+ // the fetch method will retrieve any resource and ensure the right
57
+ // secure headers are passed.
55
58
user. fetch(" https://api.github.com/user/emails" , { res2 ->
56
59
if (res2. failed()) {
57
60
// request didn't succeed because the token was revoked so we
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ public void start() throws Exception {
69
69
// The protected resource
70
70
router .get ("/protected" ).handler (ctx -> {
71
71
AccessToken user = (AccessToken ) ctx .user ();
72
-
72
+ // retrieve the user profile, this is a common feature but not from the official OAuth2 spec
73
73
user .userInfo (res -> {
74
74
if (res .failed ()) {
75
75
// request didn't succeed because the token was revoked so we
@@ -82,6 +82,9 @@ public void start() throws Exception {
82
82
final JsonObject userInfo = res .result ();
83
83
84
84
// fetch the user emails from the github API
85
+
86
+ // the fetch method will retrieve any resource and ensure the right
87
+ // secure headers are passed.
85
88
user .fetch ("https://api.github.com/user/emails" , res2 -> {
86
89
if (res2 .failed ()) {
87
90
// request didn't succeed because the token was revoked so we
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ router.get("/").handler(function (ctx) {
38
38
// The protected resource
39
39
router . get ( "/protected" ) . handler ( function ( ctx ) {
40
40
var user = ctx . user ( ) ;
41
-
41
+ // retrieve the user profile, this is a common feature but not from the official OAuth2 spec
42
42
user . userInfo ( function ( res , res_err ) {
43
43
if ( res_err != null ) {
44
44
// request didn't succeed because the token was revoked so we
@@ -51,6 +51,9 @@ router.get("/protected").handler(function (ctx) {
51
51
var userInfo = res ;
52
52
53
53
// fetch the user emails from the github API
54
+
55
+ // the fetch method will retrieve any resource and ensure the right
56
+ // secure headers are passed.
54
57
user . fetch ( "https://api.github.com/user/emails" , function ( res2 , res2_err ) {
55
58
if ( res2_err != null ) {
56
59
// request didn't succeed because the token was revoked so we
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ class Server : io.vertx.core.AbstractVerticle() {
43
43
// The protected resource
44
44
router.get(" /protected" ).handler({ ctx ->
45
45
var user = ctx.user()
46
-
46
+ // retrieve the user profile, this is a common feature but not from the official OAuth2 spec
47
47
user.userInfo({ res ->
48
48
if (res.failed()) {
49
49
// request didn't succeed because the token was revoked so we
@@ -56,6 +56,9 @@ class Server : io.vertx.core.AbstractVerticle() {
56
56
var userInfo = res.result()
57
57
58
58
// fetch the user emails from the github API
59
+
60
+ // the fetch method will retrieve any resource and ensure the right
61
+ // secure headers are passed.
59
62
user.fetch(" https://api.github.com/user/emails" , { res2 ->
60
63
if (res2.failed()) {
61
64
// request didn't succeed because the token was revoked so we
Original file line number Diff line number Diff line change 38
38
# The protected resource
39
39
router . get ( "/protected" ) . handler ( ) { |ctx |
40
40
user = ctx . user ( )
41
-
41
+ # retrieve the user profile, this is a common feature but not from the official OAuth2 spec
42
42
user . user_info ( ) { |res_err , res |
43
43
if ( res_err != nil )
44
44
# request didn't succeed because the token was revoked so we
51
51
userInfo = res
52
52
53
53
# fetch the user emails from the github API
54
+
55
+ # the fetch method will retrieve any resource and ensure the right
56
+ # secure headers are passed.
54
57
user . fetch ( "https://api.github.com/user/emails" ) { |res2_err , res2 |
55
58
if ( res2_err != nil )
56
59
# request didn't succeed because the token was revoked so we
You can’t perform that action at this time.
0 commit comments