Skip to content

OAuth Services Custom Responses

Julian Gojani edited this page Mar 15, 2021 · 3 revisions

OAuth Services Custom Responses

You can access custom information for oauth services via the get(Information) method on Profile or send custom HTTP-Requests to the specific resource server.

Example for accessing information

oAuth2Module.setOAuth2Callback((service, exchange, callback) -> {
    if (service.equals("github")) {
        return callback.getProfile().name+" is working at "+callback.getProfile().get("company").string();
    }
    return "";
});

Github

{
  "gists_url": "https://api.github.com/users/USERNAME/gists{/gist_id}",
  "repos_url": "https://api.github.com/users/USERNAME/repos",
  "two_factor_authentication": false,
  "following_url": "https://api.github.com/users/USERNAME/following{/other_user}",
  "twitter_username": "USERNAME",
  "created_at": "2018-08-19T09:45:30Z",
  "login": "USERNAME",
  "type": "User",
  "blog": "https://javawebstack.org",
  "private_gists": 4,
  "total_private_repos": 5,
  "subscriptions_url": "https://api.github.com/users/USERNAME/subscriptions",
  "updated_at": "2021-03-14T17:44:19Z",
  "site_admin": false,
  "disk_usage": 69,
  "collaborators": 0,
  "company": "@JavaWebStack",
  "owned_private_repos": 5,
  "id": 6942069,
  "public_repos": 14,
  "gravatar_id": "",
  "plan": {
    "private_repos": 10000,
    "name": "free",
    "collaborators": 0,
    "space": 673166409
  },
  "email": "info@javawebstack.org",
  "organizations_url": "https://api.github.com/users/USERNAME/orgs",
  "starred_url": "https://api.github.com/users/USERNAME/starred{/owner}{/repo}",
  "followers_url": "https://api.github.com/users/USERNAME/followers",
  "public_gists": 8,
  "url": "https://api.github.com/users/USERNAME",
  "received_events_url": "https://api.github.com/users/USERNAME/received_events",
  "followers": 9,
  "avatar_url": "https://avatars.githubusercontent.com/u/...",
  "events_url": "https://api.github.com/users/USERNAME/events{/privacy}",
  "html_url": "https://github.com/USERNAME",
  "following": 11,
  "name": "TEST USER",
  "location": "Germany",
  "node_id": "NODEIDNODEID"
}

Google

{
  "name": "USERNAME",
  "id": "USERID",
  "verified_email": "true",
  "given_name": "NICKNAME",
  "locale": "de",
  "email": "info@javawebstack.org",
  "picture": "https://lh3.googleusercontent.com/a-/PROFILEPICTURE"
}

Discord

{
  "flags": 0,
  "verified": true,
  "mfa_enabled": false,
  "id": "USERID",
  "avatar": "AVATARHASH",
  "public_flags": 0,
  "locale": "de",
  "email": "info@javawebstack.org",
  "username": "USERNAME",
  "discriminator": "6969"
}

InteraApps

{
  "birthday": "2000-01-11",
  "mail": "info@javawebstack.org",
  "favorite_color": "#4542F4",
  "success": true,
  "name": "USERNAME",
  "description": "Description",
  "profile_picture": "https://cdn.interaapps.de/....png",
  "id": 1
}

Clone this wiki locally