Java Spring : OAuth authentication failed: Unknown Error

标签 java spring oauth

我正在尝试在 Spring 中运行一个示例 OAuth 客户端。当我运行应用程序时,我收到异常: org.springframework.security.oauth.consumer.OAuthRequestFailedException:OAuth身份验证失败:未知错误

异常中没有更多详细信息,我尝试调试代码以查看它在哪里失败,但没有运气。

如何解决此类问题?

以下是应用程序上下文中的身份验证管理器配置:

    <authentication-manager>
        <authentication-provider>
            <user-service>
                <user name="user" password="pass" authorities="ROLE_USER"/>
            </user-service>
        </authentication-provider>
    </authentication-manager>

    <oauth:consumer resource-details-service-ref="resourceDetails" oauth-failure-page="/error">
        <oauth:url pattern="/person/login" resources="resource"/>
    </oauth:consumer>

    <beans:bean id="consumerService" class="com.apple.ist.idms.service.impl.PersonServiceImpl">
        <beans:property name="personURL" value="${person-details-url}"/>
        <beans:property name="consumerTemplate">
            <beans:bean class="org.springframework.security.oauth.consumer.client.OAuthRestTemplate">
                 <beans:constructor-arg ref="resource"/>
            </beans:bean>
        </beans:property>
    </beans:bean>

    <beans:bean id="oauthInputs" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <beans:property name="location" value="classpath:apple-idms-oauth-config.properties"/>
    </beans:bean>

    <oauth:resource-details-service id="resourceDetails">
        <oauth:resource id="resource"
                        key="${consumer-key}"
                        secret="${consumer-secret}" request-token-url="${request-token-url}"
                        user-authorization-url="${user-authorization-url}"
                        access-token-url="${access-token-url}"
                        request-token-method="${request-token-method}"
                        access-token-method="${access-token-method}">
        </oauth:resource> 

最佳答案

检查来源herehere 。有两个地方创建此消息。 您似乎错过了 oauth:resource

中的某些内容

关于Java Spring : OAuth authentication failed: Unknown Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58512355/

相关文章:

java - Spring应用服务器通过websocket向客户端传输数据

authentication - 限制 Azure 身份提供商

c# - 健全性检查 Microsoft Graph API 并从 Postman 生成 OAuth token

java - 通过使用 LIKE 的查询来查询左大括号

java - 如何获取xml的命名空间

java - Hibernate 一对多映射与附加关系表

java - SimpleDateFormat 在将日期转换为字符串时更改日期

java - Hibernate如何获取更新的属性

java - Spring:委托(delegate)给自定义代理包装器进行接口(interface)注入(inject)

ios - 使用 asana 的 oauth 授权(重定向 url)