ios – Spring Security 6 + Apple OAuth2 Login


https://appleid.apple.com/auth/authorize?response_mode=form_post&response_type=code&client_id=com.myApp.app&scope=name%20email&state=PHy_dYQkLy8iQGmtWv6j3Wwc8g1jSVmAldOkkx2C5no%3D&redirect_uri=https://myDomain/login/oauth2/code/apple

^This is the URL that gets generated.

{
  "iss": "TeamID",
  "iat": 1706478326,
  "exp": 1722030326,
  "aud": "https://appleid.apple.com",
  "sub": "com.myApp.app"
}

^This is in my client secret , which is a JWT

But for some reason, after it does not work. appleid.apple.com says “invalid_request – Invalid client id or web redirect url.”

In my properties file, I set:


spring.security.oauth2.client.registration.apple.client-id=com.myApp.app
spring.security.oauth2.client.registration.apple.client-secret=MYSECRET
spring.security.oauth2.client.registration.apple.redirect-uri={baseUrl}/login/oauth2/code/{registrationId}
spring.security.oauth2.client.registration.apple.authorization-grant-type=authorization_code
spring.security.oauth2.client.registration.apple.scope=name,email
spring.security.oauth2.client.registration.apple.client-authentication-method=CLIENT_SECRET_POST
spring.security.oauth2.client.provider.apple.authorization-uri=https://appleid.apple.com/auth/authorize?response_mode=form_post
spring.security.oauth2.client.provider.apple.token-uri=https://appleid.apple.com/auth/token
spring.security.oauth2.client.provider.apple.jwk-set-uri=https://appleid.apple.com/auth/keys

Also, I set up Service ID, registered the same redirect URL and domain and connected it to the App ID.

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img