pilcrowOnPaper / arctic

OAuth 2.0 clients for popular providers
MIT License
886 stars 58 forks source link

Error using apple.validateAuthorizationCode(code) #134

Closed Ionmi closed 4 months ago

Ionmi commented 4 months ago

Hi,

I'm encountering an error when passing the Apple code to validateAuthorizationCode. The error message is "Invalid character":

Error: Invalid character:

at Base64Encoding.decode(.../node_modules/oslo/dist/encoding/base64.js:67:27)
at decodeBase64(.../node_modules/oslo/dist/encoding/base64.js:92:19)
at parsePKCS8PEM(.../node_modules/arctic/dist/providers/apple.js:64:12)
at Apple.createClientSecret(.../node_modules/arctic/dist/providers/apple.js:50:46)
at Apple.validateAuthorizationCode(.../node_modules/arctic/dist/providers/apple.js:25:37)
at Module.validateAppleAuthorizationCode

By the way I love what you are doing.

Thank you!

Ionmi commented 4 months ago

There where \n in the .p8

zestsystem commented 4 months ago

@Ionmi I am facing the same issue. what did you do to fix this?

Ionmi commented 4 months ago

@zestsystem The issue wasn't with the authorization code but with the Apple certificate instead. Internally, the function uses the certificate, and there were '\n' characters in it, which caused it to be undecodable.

zestsystem commented 4 months ago

@Ionmi Thank you so much! I would've never guessed that certificate was causing the issue