oauth2-server-php icon indicating copy to clipboard operation
oauth2-server-php copied to clipboard

{"error":"redirect_uri_mismatch","error_description":"The redirect URI is missing or do not match","error_uri":"http:\/\/tools.ietf.org\/html\/rfc6749#section-4.1.3"}

Open youngda opened this issue 8 years ago • 10 comments

youngda avatar Jan 24 '18 01:01 youngda

Go in to src/server.php find redirect_uri exact match setting it is true turn it to false and try again

akshar001 avatar Mar 13 '18 04:03 akshar001

I made that change in src/OAuth2/Server.php: $this->config = array_merge(array( 'use_jwt_access_tokens' => false, 'jwt_extra_payload_callable' => null, 'store_encrypted_token_string' => true, 'use_openid_connect' => false, 'id_lifetime' => 3600, 'access_lifetime' => 3600, 'www_realm' => 'Service', 'token_param_name' => 'access_token', 'token_bearer_header_name' => 'Bearer', 'enforce_state' => true, 'require_exact_redirect_uri' => false, 'allow_implicit' => false, 'allow_credentials_in_request_body' => true, 'allow_public_clients' => true, 'always_issue_new_refresh_token' => false, 'unset_refresh_token_after_use' => true, ), $config);

But I still get the same error...

gabeblack avatar May 03 '18 04:05 gabeblack

Note, I did have to create an .htaccess file with:

SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

in order to get the token.php to work per the install guide. (I was running in to the issue reported here: https://github.com/bshaffer/oauth2-server-php/issues/925 )

gabeblack avatar May 03 '18 04:05 gabeblack

I guess my issue wasn't the same. My error had: "#section-3.1.2" in it.

I found that portion of the code that referenced that section and changed the code to display the expected/measured uri and found that expected uri is what I put in for the INSERT command following the instructions on the step-by-step guide prior to trying it out on the google oauth2 playground:

Here is the error (with my added info to show the expected/measured redirect_uri: {"error":"redirect_uri_mismatch","error_description":"The redirect URI provided "https://developers.google.com/oauthplayground" is missing or does not match "http://blackdevices.com/"","error_uri":"http://tools.ietf.org/html/rfc6749#section-3.1.2"}

When following the step-by-step guide in the documentation, I had put in "http://blackdevices.com" for the redirect_uri when inserting the testclient in the db rather than http://fake. Does that mean I need to change the insert command to be https://developers.google.com/oauthplayground for the redirect_uri? Or is the "fake" some magic key word? Seems like a very manual process... I'm sure I am not doing something right...

gabeblack avatar May 03 '18 14:05 gabeblack

Hello.

I have the same problem when I click on the gitlab button, I get this error {"error":"redirect_uri_mismatch","error_description":"The redirect URI provided is missing or does not match","error_uri":"http://tools.ietf.org/html/rfc6749#section-3.1.2"}

Request URL: https://mattemost-ldap.MYDOMAIN.com:8080/oauth/authorize.php?response_type=code&client_id=cc64788861ce88fe4676d6e2fbf9ad3c198d43fd5cc2bd0d9a973d11a12f3543&redirect_uri=https%3A%2F%2Fmattermost.MYDOMAIN.com%2Fsignup%2Fgitlab%2Fcomplete&state=eyJhY3Rpb24iOissb2dpgiIsInRva2buIjoiewZxbmoeeDl3NWNkM25ueWs5j3N4cgk2MTFjb3o5dDhucnplanR0eGh2dDhtZHB3a3Q2eXJkaXdrbmNwaTd3eSJ5 Request Method: Status Code: 400 Bad Request

Alexandr-Kalinin avatar Jul 15 '19 11:07 Alexandr-Kalinin

Change the redirect uri in the clients table to https://developers.google.com/oauthplayground and it should fix this problem.

Freeman015 avatar Jul 23 '19 11:07 Freeman015

I have the same issue, but don't know where to start to fix it. Can someone provide some instructions for a beginner?

{"error":"redirect_uri_mismatch","error_description":"The redirect URI provided is missing or does not match","error_uri":"http:\/\/tools.ietf.org\/html\/rfc6749#section-3.1.2"}

Presumably, you can set the redirect_uri in two locations, so that what OAuth is looking for is what is expected. I am not sure where to set it, though.

kjrhody avatar Jun 08 '20 13:06 kjrhody

@kjrhody yes, but you need to state full problem.

akshar001 avatar Jun 10 '20 10:06 akshar001

@akshar001 We have a Meteor site that is set up to use oauth to ping a Drupal site for user credentials. From the Meteor site you click a button, which then generates a popup modal showing the Drupal page where the user can log in. After I provide my credentials and click "Submit" to log in, that is when I get the error. What should happen on Submit, is the popup would go away, the credentials would be verified, and you'd be routed to the Meteor site past this initial login page. Presumably something is going wrong either during the process of pinging Drupal for credentials, or the re-routing after they are captured.

kjrhody avatar Jun 10 '20 11:06 kjrhody

This error states that in the database field for oauth the redirect_uri is mismatched. So when from the Meteor site on submit button you clicks the redirect uri might be supplying alont with it. That's where the problem is. Can you post here the exact request and response in terms of GET methods then we can figure out and it can save your time

akshar001 avatar Jun 10 '20 14:06 akshar001