在开发环境中验证 Minecraft 账号。
这是 DevAuth 的“重生版”,经过改进和更新,并可直接作为 Fabric 模组使用。
使用方法
添加模组
通过 Maven Central(默认)
将以下内容添加到 build.gradle:
dependencies {
localRuntime 'net.litetex.mcm:dev-auth-neo:<version>'
// 更多文档:https://wiki.fabricmc.net/documentation:fabric_loom
}
通过 Modrinth
将以下内容添加到 build.gradle:
repositories {
// https://support.modrinth.com/en/articles/8801191-modrinth-maven
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
filter {
includeGroup 'maven.modrinth'
}
}
}
dependencies {
localRuntime 'maven.modrinth:dev-auth-neo:<version>'
// 更多文档:https://wiki.fabricmc.net/documentation:fabric_loom
}
快速入门
重要:DevAuth 默认处于禁用状态,以避免造成干扰。
最简单的启用方式是设置相应的系统属性:-Ddevauth.enabled=1
- 首次启动时,系统将提示您输入凭据
- 认证成功后,生成的令牌将存储在
microsoft_accounts.json 中
- 随后,令牌将被委托给游戏,游戏将像往常一样启动
配置
配置动态加载自以下位置(按优先级从高到低排序)
- 环境变量
- 以
DEVAUTH_ 为前缀
- 所有属性均为大写,并使用
_ 代替 . 或 -
- 系统属性
- 位于
~/.dev-auth-neo/config.json 的配置文件
完整的配置选项列表
常规
| 属性 |
类型 |
默认值 |
备注 |
enabled |
bool |
false |
|
account |
String |
- |
如果未设置: 将通过控制台提示输入 |
account-type |
String |
microsoft |
目前仅支持 Microsoft |
force-handle-all-tokens-as-expired |
bool |
false |
将所有现有令牌视为已过期并进行刷新 |
state-dir |
String |
自动确定
~/.dev-auth-neo) |
保存提供商登录信息的目录 |
cache-profile-info-minutes |
int |
360 6小时 |
获取到的个人资料信息(UUID 和名称)应缓存多长时间? |
Microsoft Grant-Flow 选项
注意:所有 grant-flow 选项额外以 microsoft.oauth2. 为前缀
例如 predefined-provider 因此必须定义为 devauth.microsoft.oauth2.predefined-provider
| 属性 |
类型 |
默认值 |
备注 |
grant-flow |
String |
auth-code-embedded |
见下文可用的流程 |
client-id |
String |
自动确定 |
设计用于通用覆盖,例如自定义提供商 |
scopes |
List<String> |
自动确定 |
|
auth-code-embedded 使用嵌入式浏览器的 Auth Code 流程
- 此登录机制与 Minecraft 启动器使用的机制相同
- 此工作流程使用 CEF (Chromium Embedded Framework) 下载并安装 Chromium 浏览器
- 下载大小约为 150MB
- 默认安装在
~/.dev-auth-neo/jcef
| 属性 |
类型 |
默认值 |
备注 |
use-temporary-cache-dir |
bool |
true |
创建并使用临时目录作为浏览器缓存。 如果设置为 false,所有浏览器信息(Cookie、缓存)以及可能的登录状态都将被持久化保存! |
redirect-uri |
String |
自动确定 |
设计用于通用覆盖,例如自定义提供商 |
auth-code-external 使用外部浏览器的 Auth Code 流程
- 与
auth-code-embedded 相同,但可以使用系统浏览器完成
- 启动集成 Web 服务器以在流程结束时获取令牌
- ⚠ 此流程依赖于第三方客户端/启动器
- 这些客户端完全依赖 Mojang 的明确批准,并且可能随时因任何原因被他们阻止(尽管这种情况不太可能发生)
- 第三方可以在不警告的情况下更改或删除其客户端
- 第三方可能会看到您的登录活动
- 可用的第三方:
| 属性 |
类型 |
默认值 |
备注 |
predefined-provider |
String |
devauth |
|
open-system-browser |
bool |
true |
是否应自动打开系统浏览器以显示登录页面? |
redirect-port |
int |
自动确定 |
用于集成 Web 服务器的端口 |
redirect-uri |
String |
自动确定 |
设计用于通用覆盖,例如自定义提供商 |
device-code 设备代码流程
- 此流程会生成一个简短的代码,需要借助账号在线验证
- ⚠ 此流程依赖于第三方客户端/启动器
- 这些客户端完全依赖 Mojang 的明确批准,尽管不太可能发生,但它们仍可能随时以任何理由被封锁
- 第三方可能会在未发出警告的情况下更改或删除其客户端
- 第三方可能能够查看你的登录活动
- 可用的第三方:
| 属性 |
类型 |
默认值 |
备注 |
predefined-provider |
String |
multimc |
|
常见问题
如何删除登录信息?
删除 %USERPROFILE%\.dev-auth-neo(Windows)或 ~/.dev-auth-neo(Linux)
我想切换到另一个账号
最简单的方法是什么?
设置 -Ddevauth.account=otherAccountName
安全性?
令牌存储在上述指定文件夹中的磁盘文件里。
与电脑上的所有数据一样,用户需自行负责保护其安全。
你可以在 Microsoft 账户设置 中撤销令牌。
Authenticate Minecraft accounts in development environments.
This is a "reincarnation" of DevAuth but improved, updated and available directly as a Fabric mod.
Usage
Adding the mod
via Maven Central (default)
Add the following to build.gradle:
dependencies {
localRuntime 'net.litetex.mcm:dev-auth-neo:<version>'
// Further documentation: https://wiki.fabricmc.net/documentation:fabric_loom
}
via Modrinth
Add the following to build.gradle:
repositories {
// https://support.modrinth.com/en/articles/8801191-modrinth-maven
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
filter {
includeGroup 'maven.modrinth'
}
}
}
dependencies {
localRuntime 'maven.modrinth:dev-auth-neo:<version>'
// Further documentation: https://wiki.fabricmc.net/documentation:fabric_loom
}
Quickstart
IMPORTANT: DevAuth is disabled by default, in order to be unobtrusive.
The simplest way to enable it is by setting the corresponding system property: -Ddevauth.enabled=1
- When launching for the first time you will be prompted to enter your credentials
- You will also get hints on what to do in the console/logs when required
- After the authentication was successful the generated tokens will be stored in
microsoft_accounts.json
- Future logins will try to reuse these tokens
- The tokens are then delegated to the game and it starts as usual
Configuration
The configuration is dynamically loaded from (sorted by highest priority)
- Environment variables
- prefixed with
DEVAUTH_
- all properties are in UPPERCASE and use
_ instead of . or -
- System properties
- A configuration file located in
~/.dev-auth-neo/config.json
Full list of configuration options
General
| Property |
Type |
Default |
Notes |
enabled |
bool |
false |
|
account |
String |
- |
If not set: Will be prompted via the console |
account-type |
String |
microsoft |
Currently only Microsoft is supported |
force-handle-all-tokens-as-expired |
bool |
false |
Handles all existing tokens as if they have expired and refreshes them |
state-dir |
String |
Automatically determined
~/.dev-auth-neo) |
The directory where the login information of the provider will be saved |
cache-profile-info-minutes |
int |
360 6h |
How long should fetched profile information(uuid and name) be cached? |
Microsoft Grant-Flow options
NOTE: All grant-flow options are additionally prefixed with microsoft.oauth2.
For example predefined-provider must therefore be defined as devauth.microsoft.oauth2.predefined-provider
| Property |
Type |
Default |
Notes |
grant-flow |
String |
auth-code-embedded |
See bellow for available flows |
client-id |
String |
automatically determined |
Designed as general purpose override for e.g. a custom provider |
scopes |
List<String> |
automatically determined |
|
auth-code-embedded Auth Code flow using an embedded browser
- This login mechanism is identical to the one used by Minecraft's launcher
- Therefore selected by default
- This workflow downloads and installs a Chromium browser using CEF (Chromium Embedded Framework)
- The download is around 150MB
- It's installed by default into
~/.dev-auth-neo/jcef
| Property |
Type |
Default |
Notes |
use-temporary-cache-dir |
bool |
true |
Creates and uses a temporary directory for the browser cache. If this is set to false all browser information (cookies, cache) and also possible logins will be persisted! |
redirect-uri |
String |
automatically determined |
Designed as general purpose override for e.g. a custom provider |
auth-code-external Auth Code flow using an external browser
- Same as
auth-code-embedded however this can be done with the system browser
- Starts an integrated webserver to get the tokens at the end of the flow
- ⚠ This flow depends on 3rd party clients / launchers
- These clients are totally dependent on Mojangs explicit approval and can - although unlikely to happen - be blocked at any time for any reason by them
- The 3rd party can change or delete their client without warning
- The 3rd party might be able to see your login activity
- Available 3rd parties:
| Property |
Type |
Default |
Notes |
predefined-provider |
String |
devauth |
|
open-system-browser |
bool |
true |
Should the system browser be automatically opened with the sign in page? |
redirect-port |
int |
automatically determined |
Port used for the integrated webserver |
redirect-uri |
String |
automatically determined |
Designed as general purpose override for e.g. a custom provider |
device-code Device Code flow
- This flow generates a short code that needs to be verified online with the an account
- ⚠ This flow depends on 3rd party clients / launchers
- These clients are totally dependent on Mojangs explicit approval and can - although unlikely to happen - be blocked at any time for any reason by them
- The 3rd party can change or delete their client without warning
- The 3rd party might be able to see your login activity
- Available 3rd parties:
| Property |
Type |
Default |
Notes |
predefined-provider |
String |
multimc |
|
FAQ
How do I delete the login information?
Delete %USERPROFILE%\.dev-auth-neo (Windows) or ~/.dev-auth-neo (Linux)
I want to switch to another account
What's the easiest way to do this?
Set -Ddevauth.account=otherAccountName
Security?
The tokens are stored in a file on the disk in above specified folder.
As with all data on your PC, you as a user are responsible for keeping them secure.
You can revoke tokens in the Microsoft account settings.
评论 0
登录后参与评分
还没有评论,来抢沙发吧