我正在尝试在我的应用程序中使用oauth2.0设置spring security。而且我遇到一个例外:
UnsupportedGrantTypeException,不支持的授予类型:密码
配置中是否缺少任何内容?
错误日志:
org.springframework.security.oauth2.common.exceptions.UnsupportedGrantTypeException: Unsupported grant type: password
at org.springframework.security.oauth2.provider.endpoint.TokenEndpoint.postAccessToken(TokenEndpoint.java:134) ~[spring-security-oauth2-2.2.1.RELEASE.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_201]
答案 0 :(得分:1)
我认为您的Oauth服务器不支持密码授予类型。这一个用于获取“访问令牌”。我认为您应该寻找由OAuth服务器处理的授权类型
答案 1 :(得分:0)
在授权服务器的配置中,扩展from itertools import chain
from nltk import sent_tokenize, word_tokenize
from nltk.tokenize.treebank import TreebankWordDetokenizer
word_detokenize = TreebankWordDetokenizer().detokenize
import wikipedia
text = wikipedia.page("Winnie The Pooh").content
tokenized_text = [word_tokenize(sent) for sent in sent_tokenize(text)]
sent_idx_with_china = [idx for idx, sent in enumerate(tokenized_text)
if 'China' in sent or 'china' in sent]
window = 2 # If you want 2 sentences before and after.
for idx in sent_idx_with_china:
start = max(idx - window, 0)
end = min(idx+window, len(tokenized_text))
result = ' '.join(word_detokenize(sent) for sent in tokenized_text[start:end])
print(result)
print()
时,可以为每个客户设置授权的授予类型。
AuthorizationServerConfigurerAdapter
spring-security授权服务器sample中有一个完整的示例。