如何使用spring security oauth2执行amazon sp api第三方授权

wsxa1bj1  于 2021-07-14  发布在  Java
关注(0)|答案(0)|浏览(272)

我使用了amazonspapi网站工作流
我想使用spirng安全oauth2来实现这一点。我研究了官方github和google第三方登录授权,但是我添加的自定义amazon授权不起作用。每次我重定向/login/oauth2/code/aws?spapi\u oauth\u code=x&state=x&selling\u partner\u id=xx失败。则身份验证错误无法获取accesstoken。官方将重定向到客户端以保存oauth代码和sellingpartner id。但是我想将amazon sp api第三方授权与oauth2结合起来,我不知道该怎么办

2021-04-16 18:08:07.314 DEBUG 13890 --- [nio-4000-exec-6] o.s.s.web.DefaultRedirectStrategy        : Redirecting to https://sellercentral.amazon.com/apps/authorize/consent?response_type=code&client_id=xxxxxxxxxxxx&state=_35cnIQDCeZ4LAyylz4sHEnD0_fCT0F-3wl-_C54IO8%3D&redirect_uri=https://7bee2c00684b.ngrok.io/login/oauth2/code/aws&application_id=amzn1.sp.solution.xxxxxxxxxxx-xxxxx-xxxx-xxxxxxxxxxx&version=beta
2021-04-16 18:08:07.314 DEBUG 13890 --- [nio-4000-exec-6] w.c.HttpSessionSecurityContextRepository : Did not store empty SecurityContext
2021-04-16 18:08:07.314 DEBUG 13890 --- [nio-4000-exec-6] w.c.HttpSessionSecurityContextRepository : Did not store empty SecurityContext
2021-04-16 18:08:07.314 DEBUG 13890 --- [nio-4000-exec-6] s.s.w.c.SecurityContextPersistenceFilter : Cleared SecurityContextHolder to complete request
2021-04-16 18:11:26.773 DEBUG 13890 --- [nio-4000-exec-9] o.s.security.web.FilterChainProxy        : Securing GET /login/oauth2/code/aws?spapi_oauth_code=ANqUsOscSsauIVLJaRhr&state=_35cnIQDCeZ4LAyylz4sHEnD0_fCT0F-3wl-_C54IO8%3D&selling_partner_id=A2J6UCJC3ICYAB
2021-04-16 18:11:26.773 DEBUG 13890 --- [nio-4000-exec-9] s.s.w.c.SecurityContextPersistenceFilter : Set SecurityContextHolder to empty SecurityContext
2021-04-16 18:11:26.775 DEBUG 13890 --- [nio-4000-exec-9] o.s.s.web.DefaultRedirectStrategy        : Redirecting to /loginFailure

这是配置

spring:
  security:
    oauth2:
      client:
        registration:
          github:
            clientId: xxxx
            clientSecret: xxx
          google:
            client-id: xxxxx
            client-secret: xxxxx
          aws:
            client-id: xxxxx
            client-secret: xxxxxx
            client-name: xxx
            authorization-grant-type: authorization_code
            provider: amazon
            redirect-uri: 'https://7bee2c00684b.ngrok.io/{action}/oauth2/code/{registrationId}'
        provider:
          amazon:
            authorizationUri: https://sellercentral.amazon.com/apps/authorize/consent
            tokenUri: https://api.amazon.com/auth/o2/token

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题