2016-06-01 6 views
0

죄송합니다.이 질문은 여러 번 물어 보았습니다. 여러 답변을 보았지만 답을 찾아 보았지만 행운은 없습니다. 다음 절차 내가) Google Oauth의 redirect_uri 불일치

1

을 따라 구글 개발자 콘솔에 갔다 한 것입니다
2) 자격 증명을
3) OAuth 클라이언트 ID를 만들 클릭
4) 웹 appplication은 authorsied 리디렉션 URI 년대
나는 https://www.example.com/home

했다

클라이언트 ID 인 클라이언트 비밀번호가 나타납니다. 여기에서 나는 다음과 같은 코드를 사용하여 구글의 OAuth를 호출하고 이제 그들에게

Spree::AuthenticationMethod.where(environment: Rails.env, provider: 'google_oauth2').first_or_create do |auth_method| 
    auth_method.api_key = ENV['GOOGLE_ID'] 
    auth_method.api_secret = ENV['GOOGLE_SECRET'] 
    auth_method.active = true 
    end 

을 추가 한

<a href="https://www.example.com/users/auth/google_oauth2"> 
    <div> 
     Sign up with google 
    </div> 
</a> 

편집 :

이 내가

The redirect URI in the request, https://www.example.com/users/auth/google_oauth2/callback, does not match the ones authorized for the OAuth client. Visit https://console.developers.google.com/apis/credentials/oauthclient/490969266456-ki43pu8ejosstkuv01jadmmmt1o33the.apps.googleusercontent.com?project=490969266456 to update the authorized redirect URIs. 
무엇입니까 오류가

다음은 요청입니다

Request Details 
access_type=offline 
scope=email 
response_type=code 
redirect_uri=https://www.example.com/users/auth/google_oauth2/callback 
state=31ad247324b285fdf6102e931707e041770a85990050eb40 
client_id=490969266456-ki43pu8ejosstkuv01jadmmmt1o33the.apps.googleuserc 

위의 메시지를보고 나서 콘솔에 들어가서 리디렉션 URI를 https://www.example.com/users/auth/google_oauth2/callback으로 업데이트했습니다. 여전히 동일한 오류가 발생합니다.

+0

오류가 발생합니까? –

+0

예 제목은 내가 받고있는 오류입니다 – gates

+0

URL에 클라이언트 ID를 보내겠습니까? – gates

답변

2

그래서 문제가 발생했습니다. 적절한 리디렉션 URI가없는 계정 하나를 만들었습니다. 나는 새로운 자격 증명을 생성, 내가 알고 왔을 때 여기

Spree::AuthenticationMethod.where(environment: Rails.env, provider: 'google_oauth2').first_or_create do |auth_method| 
    auth_method.api_key = ENV['GOOGLE_ID'] 
    auth_method.api_secret = ENV['GOOGLE_SECRET'] 
    auth_method.active = true 
    end 

을 나중에, 나는 콘솔에서 적절한 콜백 URL을 넣어해야한다고했다. .env 파일에서 업데이트했습니다.

하지만 Spree :: AuthenticationMethod.all에서 업데이트하지 않은 것 같습니다. 이전 키가 나타납니다. 그래서 나는 그 기록을 삭제하고 rails s을했습니다.

새로운 키가 레일 콘솔에 나타납니다. 이 href가 같은 요청할 때 기억해야 할

또 다른 점은 같아야 다시 URI 구글 콘솔에서 통화> "https://www.example.com/users/auth/google_oauth2"=

입니다 이

https://www.example.com/users/auth/google_oauth2/callback

+0

좋은 설명. –