Accedia / appleauth-net

AppleAuth.NET is a simple library that facilitates the implementation of "Sign in with Apple" for .NET applications.
MIT License
46 stars 26 forks source link

invalid_grant error #12

Closed ghost closed 3 years ago

ghost commented 3 years ago

I'm trying to implement this plugin, however I keep getting the "invalid_grant" error.

I've set up an "Apple Sign In" service in my Apple developer account, and I'm using the key id from this service.

However I'm using null for the redirect URL, as I'm using this in conjunction with an app. This means there's no redirect going on, as the server is merely validating the token.

Could this be why, and if that's the case, how do I go about solving it?

ghost commented 3 years ago

Slight update, after reading this: https://developer.apple.com/documentation/sign_in_with_apple/generate_and_validate_tokens which states: When authorizing a user with your app, include the redirect_uri parameter only if the application provided a redirect_uri in the initial authorization request. I forked your repository and stripped out the redirect_uri parameter when it's null. Alas this didn't change anything, so I still get the invalid grant error.

Hope this update helps in identifying what's going wrong.

DanailStoichkov commented 3 years ago

Hello, From what I know the redirect_uri is a required parameter, as the documentation states: Authorization code requests require this parameter. I think you need to have it configured in both the developer portal and code and it should be using https:// and it can't be localhost.

ghost commented 3 years ago

Thanks for the reply, it just seems odd for flows like mine where there's no website involved. Guess I'll have to figure something else out then. I'll close the issue.