Multiple client ids spring security config

倾然丶 夕夏残阳落幕 提交于 2019-12-06 07:39:08

问题


I have successfully implemented Google Sign-In on iOS with following application.yml:

security:
  oauth2:
    resource:
      user-info-uri: https://www.googleapis.com/plus/v1/people/me
      prefer-token-info: true
    client:
      client-id: xxxxx.apps.googleusercontent.com
      access-token-uri: https://www.googleapis.com/oauth2/v3/tokeninfo
      client-authentication-scheme: form
      scope: email,profile

Now I need to add configuration for Android client. Obviously I cannot do this:

security:
  oauth2:
    resource:
      user-info-uri: https://www.googleapis.com/plus/v1/people/me
      prefer-token-info: true
    client:
      client-id: xxxxx.apps.googleusercontent.com
      access-token-uri: https://www.googleapis.com/oauth2/v3/tokeninfo
      client-authentication-scheme: form
      scope: email,profile
    client:
      client-id: xxxxx.apps.googleusercontent.com
      access-token-uri: https://www.googleapis.com/oauth2/v3/tokeninfo
      client-authentication-scheme: form
      scope: email,profile

What is the correct approach and best practice to do this?


回答1:


I found the syntax you are looking for from this file Will Tran Github project application.yml

It will look like this,

# OAuth2 Details
security.oauth2:
    client:
        client-id: client001
        client-secret: pwd001
        authorized-grant-types: password,authorization_code,refresh_token
        scope: read,write

---

security.oauth2:
    client:    
        client-id: client002
        client-secret: pwd002
        authorized-grant-types: client_credentials
        scope: TRUSTED

---

# /\ Dont forget this one

Ps.: Check the link for better reference.



来源:https://stackoverflow.com/questions/39332539/multiple-client-ids-spring-security-config

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!