Sign in with Apple REST API

RSS for tag

The Sign in with Apple REST API allows your app's servers to communicate with Apple’s authentication servers.

Sign in with Apple REST API Documentation

Pinned Posts

Posts under Sign in with Apple REST API tag

50 Posts
Sort by:
Post not yet marked as solved
0 Replies
979 Views
Hello, I need to use a apple sign in in ios application, i get my authorization code from hybryde apllication : let options: SignInWithAppleOptions = { clientId: ConstConfig.APPLE_CLIENT_ID, redirectURI: ConstConfig.APPLE_REDIRECT_URI, scopes: ConstConfig.APPLE_SCOPES, state: ConstConfig.APPLE_STATE, nonce: ConstConfig.APPLE_NONCE }; SignInWithApple.authorize(options) .then((result: SignInWithAppleResponse) => { this.authenticate.appleAuthorizationCode = result.response.authorizationCode; this.authenticate.appleUser = result.response.user; this.authenticate.appleIdentityToken = result.response.identityToken; i send this 3 value to my backend JAVA to validate the accessToken and get the refrsh token, validate java Method : logger.info("Apple authorization validation"); // get the subject received from the client String clientSubject = getSubject(identityToken); // verifying the code by the apple server String token = getToken(); logger.debug("Authorize with token:" + token); Map<String, String> params = new HashMap<>(); params.put("client_id", APPLE_CLIENT_ID); params.put("client_secret", token); params.put("code", authorisationCode); params.put("grant_type", "authorization_code"); params.put("redirect_uri", ""); if (redirectURI != null) { } String response = post(APPLE_AUTH_URL, params); logger.info("Apple authorization response:" + response); AppleTokenResponse tokenResponse = objectMapper.readValue(response, AppleTokenResponse.class); if (tokenResponse.getError() != null && tokenResponse.getError().length() > 0) { logger.warn("Error during verification of the code. Reason:" + tokenResponse.getError()); return null; } String serverSubject = getSubject(tokenResponse.getId_token()); if (!serverSubject.equals(clientSubject)) { logger.warn("Validation failed, subject does not match!"); return null; } return getClaims(tokenResponse.getId_token()); the JWT TOken : return Jwts.builder() .setHeaderParam(JwsHeader.KEY_ID, APPLE_KEY_ID) .setHeaderParam(JwsHeader.ALGORITHM,"ES256") .setIssuer(APPLE_TEAM_ID) .setAudience(APPLE_APPLE_ID_URL) .setSubject(APPLE_CLIENT_ID) .setExpiration(new Date(System.currentTimeMillis() + (1000 * 60 * 5))) .setIssuedAt(new Date(System.currentTimeMillis())) .signWith(SignatureAlgorithm.ES256, pKey) .compact(); how i get my private key : File file = new File(APPLE_CERTIFICATE_PATH); try { PEMParser pemParser = new PEMParser(new FileReader(file)); JcaPEMKeyConverter converter = new JcaPEMKeyConverter(); PrivateKeyInfo object = (PrivateKeyInfo) pemParser.readObject(); APPLE_PRIVATE_KEY = converter.getPrivateKey(object); logger.info("load apple private keys Ok."); } catch (Exception ex) { logger.error("error on generate apple sign in private Key : ", ex); } thr response still return : {"error":"invalid_grant","error_description":"client_id mismatch. The code was not issued to bundleID"}, i don't know the reason. i read that i nedd to check in testFlit, ido but i still get the same error, i also put the same redirect_url in front and back (for me that not needed because i dont use u web sign in ) but i still get the same error. for my bundle id i use the APP Identifier not the service Identifier in front and back. its correct ? thank for your help.
Posted
by djrhTYU.
Last updated
.
Post marked as solved
3 Replies
7.3k Views
After successfully logging in using apple sign-in. I get back the default response: the authorization code. I send the entire payload to my backend to which I then, use the docs - https://developer.apple.com/documentation/sign_in_with_apple/generate_and_validate_tokens to verify the auth_code. I get back this response. { "error": "invalid_grant", "error_description": "client_id mismatch. The code was not issued to com.example.bundle." } I've checked the bundleId several times. I've created new Identifiers and keys, used those new values instead and I get the same issue. According to the errorResponse - https://developer.apple.com/documentation/sign_in_with_apple/errorresponse documentation: invalid_grant The authorization grant or refresh token is invalid, typically due to a mismatched or invalid client identifier, invalid code (expired or previously used authorization code), or invalid refresh token. Any recommended test solutions to diagnose this issue?
Posted
by tony308.
Last updated
.
Post not yet marked as solved
1 Replies
1k Views
Hey i am trying to Link Zelle API with SWIFT Based Ecommerce Store , Getting error code 8889275440 , and 18889275440 , Am trying to track and put balance into users account as i receive the payment from user and post directly to his account when he tries to add funds , But getting the above two error codes
Posted Last updated
.
Post not yet marked as solved
0 Replies
802 Views
I have the below code block to call the token endpoint. The endpoint succeeds from Postman with JSON response but from my web application, it fails with CORS error. What could be the reason for this behavior? const axios = require('axios'); const qs = require('qs'); let data = qs.stringify({ 'grant_type': 'authorization_code', 'code': 'xxxxxxyyyyybbb, 'redirect_uri': 'https:myApp/login', 'client_id': 'com.myclient_id', 'client_secret': 'myworkingsecret' }); let config = { method: 'post', maxBodyLength: Infinity, url: 'https://appleid.apple.com/auth/token', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, data : data }; axios.request(config) .then((response) => { console.log(JSON.stringify(response.data)); }) .catch((error) => { console.log(error); });
Posted
by Philipmvp.
Last updated
.
Post not yet marked as solved
0 Replies
747 Views
We are implementing a web app with Angular as frontend and java springboot as backend. while trying to use signin with Appleid in our application login page, we are getting Invalid_Client. please find the attached log and image of error. log.txt
Posted Last updated
.
Post not yet marked as solved
0 Replies
639 Views
Hey i am trying to integrate my api with my machine for some testing work but it is showing me an error code possibility combinations 18336324201 , 08336324201 , 8336324201 , Can anyone help me out fixing this i have been working really hard for this project
Posted
by Alen08121.
Last updated
.
Post not yet marked as solved
1 Replies
861 Views
In the app I am currently creating, I want to make the user logged in only after signing in with apple and making in-app purchases. In other words, if the user only creates an account and does not make in-app purchases, he/she is not logged in, and we do not want to display the "delete account" button. However, if the user leaves the app without making an in-app purchase, the account information will be kept on the server. I understand that after 6/30/2022, users must be able to delete their accounts. Can we use a batch process to periodically delete accounts that have not made in-app purchases and hit the API for token deletion to satisfy the app's review requirements? Also, would it be a problem if we mention in the terms of service, etc. that accounts that have not made in-app purchases are to be deleted periodically?
Posted Last updated
.
Post not yet marked as solved
0 Replies
494 Views
We are currently developing a new iOS application, and we plan to use Sign in with Apple for user authentication. We have a few questions related to this. We understand that Sign in with Apple is compliant with OpenID Connect. However, in our service, the use cases for access_token and refresh_token are limited. Therefore, even if we do not use these tokens, is there a possibility that we will receive a rejection in the Apple Store Review process? Specifically, we are thinking of saving the user's identifier, which can be obtained at the time of authentication, on our server and using it to identify the user. ASAuthorizationAppleIDCredential According to Apple's guidelines (5.1.1 Data Collection and Storage), we need to invalidate the user's tokens when the account is deleted. Does this requirement apply even if the token has already expired? App Store Review Guidelines 5.1.1 Revoke tokens Thank you in advance for your help!
Posted
by HTSIIM.
Last updated
.