Posts

Post not yet marked as solved
6 Replies
3.7k Views
When I run `curl https://subdomain.example.com/.well-known/apple-developer-domain-association.txt` (not the real subdomain/domain), I get a hit in my server logs:2019-09-09T22:51:23.294771+00:00 heroku[router]: at=info method=GET path="/.well-known/apple-developer-domain-association.txt" host=subdomain.example.com request_id=0a924401-0e45-4713-a9b3-600d657d5c57 fwd="xx.xx.***.***" dyno=web.1 connect=1ms service=4ms status=200 bytes=5961 protocol=httpsAnd the validation certificate is returned are returned. (e.g. "MIIP5AYJKoZIhvcNAQcCoIIP1TCC..."). But, when I press the "Verfy" button on my Service ID "Web Authentication Configuration" dialog for Apple SSO, "Verification failed for domain" is returned but no request arrives at my server. No new logs are created. The browser developer tools XHR console for the request simply returns:{ creationTimestamp: "2019-09-09T22:54:49Z" httpCode: 200 protocolVersion: "QH65B2" requestUrl: "https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/verifyDomain" responseId: "70f5f9b0-a342-4eac-a527-df7f2981401e" resultCode: 13004 resultString: "Verification failed for domain" userLocale: "en_US" userString: "Verification failed for domain" }How can I learn more about the issue? This seems like there's a bug on the Apple Servers that''s preventing the request from being sent off. Could it be because the domain I'm trying to validate has a dash in it? (e.g. sub-domain.example.com)
Posted
by birdsean.
Last updated
.
Post marked as solved
2 Replies
3.9k Views
After following the SSO flow, my api gets a form-encoded post that looks like the following:Parameters: {"state"=>"x", "code"=>"y", "id_token"=>"z"}I then attempt to validate the code by calling `validate_auth_token`def validate_auth_token(token, is_refresh = false) uri = URI.parse('https://appleid.apple.com/auth/token') https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true headers = { 'Content-Type': 'text/json' } request = Net::HTTP::Post.new(uri.path, headers) request_body = { client_id: @client_id, client_secret: retreive_client_secret } if is_refresh request_body[:grant_type] = 'refresh_token' request_body[:refresh_token] = token else request_body[:grant_type] = 'authorization_code' request_body[:code] = token request_body[:redirect_uri] = "https://#{Rails.application.secrets.backend_host_port}/apple" end pp request_body request.body = request_body.to_json response = https.request(request) p JSON.parse response.body p response.code end private def retreive_client_secret cert = retreive_secret_cert ecdsa_key = OpenSSL::PKey::EC.new cert algorithm = 'ES256' headers = { 'alg': algorithm, 'kid': @key_id } claims = { 'iss': @team_id, 'iat': Time.now.to_i, 'exp': Time.now.to_i + 5.months.to_i, 'aud': 'https://appleid.apple.com', 'sub': @client_id } token = JWT.encode claims, ecdsa_key, algorithm, headers token endwhere @client_id is the "Service ID" I submitted in the initial SSO request, @key_id is the id of the private key downloaded from the apple key dashboard, and @team_id is our apple team id.No matter how I mishape the validation request, I continue to get a 400 response with an "unsupported_grant_type" error. The docs say that this means that: The authenticated client is not authorized to use the grant type.I've enabled Apple SSO on the App Id, the Service Id, and have even verified my support email domains. What am I missing? Is there some other approval step I need to complete to get authorized?
Posted
by birdsean.
Last updated
.