问题
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