Oauth2 Instagram API “redirect URI does not match registered redirect URI”

前端 未结 10 1658
甜味超标
甜味超标 2020-12-15 06:41

I am working on a Rails application which is in development mode and it can register with omniauth.

The host is

http://localhost:3000/
10条回答
  •  时光取名叫无心
    2020-12-15 07:19

    For anyone that is having this issue and the redirect uri provided to instagram is exactly the same as the one you're using, i've found that some users were typing my website address as http://www.example.com/login when in my instagram api it was http://example.com/login.

    Then I created a php script to detect if the string www exists in my url and then reload to the same page but without the www.

    if(strpos($_SERVER['HTTP_HOST'], 'www.') !== FALSE) {
        header("Location: ".str_replace('www.', '', $_SERVER['HTTP_HOST'].'/'.$_SERVER['REQUEST_URI']));
    }
    

提交回复
热议问题