Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sign In With Apple JS returns 'invalid_request: Invalid redirect_uri.'

I've started integrating Sign In With Apple to my website, but I'm having some issues. I THINK I've configured Sign In With Apple on their end as it should be.

Developer

Developer 2

Code

Next, I configured my HTML/CSS/JS as I saw on an article. When I click the "Sign In With Apple" button, it takes me to this screen:

enter image description here

I've been struggling with this for hours, what am I doing wrong?

Thanks, Jackson

like image 365
Jackson Zamorano Avatar asked Apr 07 '20 02:04

Jackson Zamorano


3 Answers

I had the same problem. A few things tripped me up:

  1. In Apple Dev portal, your "Return URLs" need to have "https://", e.g. https://myawesomepwa.com. Meanwhile, the "domains and subdomains cannot have https; it must be the bare domain, e.g. myawesomepwa.com.

  2. Make sure all the URLs you specify don't have a trailing slash.

  3. In your JS code, make sure your redirect URL doesn't have a trailing slash:

Example JS code:

AppleID.auth.init({
    clientId : this.clientId,
    scope : "email",
    redirectURI : "https://myawesomepwa.com",
    state : "initial",
    usePopup : true
});

Once I did that, Sign in With Apple started working.

like image 101
Judah Gabriel Himango Avatar answered Oct 22 '22 12:10

Judah Gabriel Himango


In my case the error message 'invalid_request: Invalid redirect_uri.' was badly misleading! The problem was that I did not create a Key in "Certificates, Identifiers & Profiles/Keys".

So: Click + to create a new Key -> Enter a name and check Sign in with Apple -> Click configure button next to the checkbox -> select your Primary App ID.

I followed this tutorial: Sign In with Apple: Learn About the New Identity Provider

like image 41
Lopuch Avatar answered Oct 22 '22 13:10

Lopuch


Seems like you have solved it, I think the issue was the trailing slash on the redirect_uri, removing it might solve this issue.

like image 1
Axel Avatar answered Oct 22 '22 12:10

Axel