{"id":19839014,"url":"https://github.com/litarvan/openauth","last_synced_at":"2025-05-01T18:31:49.214Z","repository":{"id":31652117,"uuid":"35217438","full_name":"Litarvan/OpenAuth","owner":"Litarvan","description":"Java Yggdrasil library.","archived":false,"fork":false,"pushed_at":"2024-01-17T01:36:30.000Z","size":347,"stargazers_count":159,"open_issues_count":17,"forks_count":29,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-06T16:53:40.018Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Litarvan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-05-07T11:57:40.000Z","updated_at":"2025-03-17T18:38:59.000Z","dependencies_parsed_at":"2024-11-12T12:30:07.954Z","dependency_job_id":null,"html_url":"https://github.com/Litarvan/OpenAuth","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Litarvan%2FOpenAuth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Litarvan%2FOpenAuth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Litarvan%2FOpenAuth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Litarvan%2FOpenAuth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Litarvan","download_url":"https://codeload.github.com/Litarvan/OpenAuth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251924812,"owners_count":21666039,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T12:19:55.329Z","updated_at":"2025-05-01T18:31:48.696Z","avatar_url":"https://github.com/Litarvan.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"![OpenAuth Logo](./banner.png)\n\n\u003e Minecraft authentication library which supports both Mojang and Microsoft accounts, or even custom servers\n\n# Credits\n\nThis project would have not existed without the work from:\n\n - [Kronos666](https://github.com/Kronos666) for Mojang authentication\n - [Alexis Bize](https://github.com/Alexis-Bize) for Microsoft authentication\n - [Mickaël Guessant](https://github.com/mguessan) for Microsoft webview authentication\n\n# Importing library\n\n## Gradle\n```gradle\nrepositories {\n    maven {\n        url 'https://litarvan.github.io/maven'\n    }\n}\n\ndependencies {\n    implementation 'fr.litarvan:openauth:1.1.3'\n}\n```\n\n## Maven\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003elitarvan\u003c/id\u003e\n        \u003curl\u003ehttps://litarvan.github.io/maven\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003efr.litarvan\u003c/groupId\u003e\n        \u003cartifactId\u003eopenauth\u003c/artifactId\u003e\n        \u003cversion\u003e1.1.3\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n## Other\nUse the JAR file from releases, or from the GitHub Actions.\n\n# How to use it (Microsoft)\n\n```java\nMicrosoftAuthenticator authenticator = new MicrosoftAuthenticator();\nMicrosoftAuthResult result = authenticator.loginWithCredentials(\"email\", \"password\");\n      // Or using a webview: authenticator.loginWithWebView();\n  // Or using refresh token: authenticator.loginWithRefreshToken(\"refresh token\");\n   // Or using your own way: authenticator.loginWithTokens(\"access token\", \"refresh token\");\n        \nSystem.out.printf(\"Logged in with '%s'%n\", result.getProfile().getName());\n```\n\nYou can save the refresh token (`result.getRefreshToken()`) to log back the user silently later.\n\n# How to use it (Mojang)\nUse it to connect to any yggdrasil server (The Mojang official auth server, or any openauth server, and maybe other servers !)\n\n## Init it\nFirst init the authenticator with settings from your server : \n```java\nAuthPoints points = new AuthPoints(\"authpage\", \"refreshpage\", \"validatepage\", \"signoutpage\", \"invalidatepage\");\nAuthenticator authenticator = new Authenticator(\"urlofyourserver\", points);\n```\n\nSo the auth points are the url (relative to the main url) of all your page, you can give only page that you wan't to use !\nurlofyourserver is of course the URL of yout Yggdrasil server.\n\nYou can use pre-made auth points : AuthPoints.MOJANG_AUTH_POINTS or AuthPoints.OPENAUTH_AUTH_POINTS\nYou can alose user the official mojang server : Authenticator.MOJANG_AUTH_URL\n\n## Send a request !\n### Authenticate\nReceive an access token by authenticating an user\n```java\nAuthResponse response = authenticator.authenticate(authagent, \"username\", \"password\", \"clientToken\");\n```\n\nSo, replace auth agent with your auth agent (Minecraft, Scrolls, or other) pre-made agent are AuthAgent.MINECRAFT and AuthAgent.SCROLLS. Auth Agent are used to get the profile of the account of your server, every accounts have some profiles, one profile is one game, so to create yout auth agent object, use :\n```java\nAuthAgent myAgent = new AuthAgent(\"name\", version);\n```\nYou can manage the profiles in the server ^^\nThe Auth agent is optional, if you don't send it, response.getSelectedProfile() and response.getAvailableProfiles() will be null.\n\nReplace username with the username of the user account, and password with the password of the user account you wanna auth !\n\nThe client token is like a key to protect the access token if you wan't, it is optional !\n\nEvery profiles has a username and an ID, user (profile).getName() and (profile).getId() to get them !\n\n### Refresh\nReceive a new access token by re-authenticating an user with the saved access token of the previous authentication\n```java\nRefreshResponse response = authenticator.refresh(\"accessToken\", \"clientToken\");\n```\n\nReplace accessToken by the saved access token from the previous authentication of the user you wanna re-auth, and clientToken by the client token given when authenticating (optinal if you didn't give it)\n\nThe reponse is near the same as the auth response (selectedProfile, accessToken, etc...)\n\n### Validate\nThis is to check an access token, WARNING : This method should not be used by the client. Juste do\n```java\nauthenticator.validate(\"accessToken\");\n```\n\n### Signout\nInvalidate an access token using the username and the password of the user that had the access token\n```java\nauthenticator.signout(\"username\", \"password\");\n```\n\n### Invalidate\nInvalidate an access token using the access token and its client token\n```java\nauthenticator.invalidate(\"accessToken\", \"clientToken\");\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flitarvan%2Fopenauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flitarvan%2Fopenauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flitarvan%2Fopenauth/lists"}