我可以使用 grant_type="password" 获取 refresh_token 刷新 access_token 访问我的 API

Can I use grant_type="password" to obtain refresh_token to refresh access_token to access my API

我创建了一项服务,无需用户交互即可访问我的 API。 Api 需要了解用户。因此我需要资源所有者流程。

为了访问我的 Api,我需要一个具有正确范围 "MyApiScope" 的 access_token。 我可以通过指定 scope="MyApiScope" 的资源所有者流程获得 access_token。但是我不会以这种方式获得刷新令牌。

我可以通过指定范围="offline_access" 的资源所有者流程获得refresh_token。但是使用此刷新令牌生成的 access_token 不能用于访问我的 Api,因为它们不包含正确的范围,"offline_access" != "MyApiScope".

在这种情况下是否不可能使用刷新令牌,因此我是否应该始终使用 username/password 来获取新的 access_token?

感谢您的建议。

只需添加以空格分隔的所有必需范围。
grant_type=password&username={USERNAME}&password={PASSWORD}&‌​client_id={CLIENT_ID‌​}&client_secret={CLI‌​ENT_SECRET}&scope=My‌​ApiScope offline_access