Skip to content

Commit

Permalink
Merge branch 'master' of github.com:PhilJay/APNJWT
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Jahoda committed Feb 28, 2022
2 parents 4b447f1 + 4389930 commit 7c6df5f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ If you want to decode a JWT String, create a JSON decoder:
return gson.fromJson(json, JWTAuthHeader::class.java)
}

override fun palyoadFrom(json: String): JWTAuthPayload {
override fun payloadFrom(json: String): JWTAuthPayload {
return gson.fromJson(json, JWTAuthPayload::class.java)
}
}
Expand All @@ -124,11 +124,11 @@ Use the json decoder to decode your token String:

## Verifying

In order to verify a JWT received from Sign in with Apple, securely transmit it to your backend, then [obtain a JWK (Json Web Key) from Apple](https://developer.apple.com/documentation/signinwithapplerestapi/fetch_apple_s_public_key_for_verifying_token_signature) and use it as a public key for verification:
In order to verify a JWT received from **Sign in with Apple**, securely transmit it to your backend, then [obtain a JWK (Json Web Key) from Apple](https://developer.apple.com/documentation/signinwithapplerestapi/fetch_apple_s_public_key_for_verifying_token_signature) and use it as a public key for verification:

```kotlin
val jwk: JWKObject = ... // fetch JWK (public key) from Apple endpoint
val tokenString = "ey..." // the JWT to validate
val jwk: JWKObject = ... // fetch current JWK (public key) from Apple endpoint
val tokenString = "ey..." // the token to validate / verify (obtained from Sign in with Apple)

// turns JWK into RSA public key, returns true if validation is successful
val valid = JWT.verify(tokenString, jwk, decoder)
Expand Down

0 comments on commit 7c6df5f

Please sign in to comment.