2013-05-07 15 views
7

tarihinde Oauth 2.0 docs göre devlet parametresi:hakkında OAuth 2 ve devlet parametre değerleri yönlendirme url kayıtlı olması gerekir

Indicates any state which may be useful to your application upon receipt of the response. The Google Authorization Server roundtrips this parameter, so your application receives the same value it sent. Possible uses include redirecting the user to the correct resource in your site, nonces, and cross-site-request-forgery mitigations.

bildiğim için bir araç olarak devlet parametre kullanmak istediğiniz alt alan adı orijinal oauth isteğinden başlatıldı. Ancak, redirect_state parametresinin "Yetkili Yönlendirme URI'lerinden" birinin parçası olarak kaydedilmesi gerekiyor gibi görünüyor. Değilse, alıyorum:

Error: redirect_uri_mismatch The redirect URI in the request: http://my_server.com/complete/google-oauth2/?redirect_state=2 did not match a registered redirect URI

ben çok sürdürülebilir olmadığı için yetkili yönlendirme URI'larda olası her redirect_state değerini kayıt gerektirmeyen bir çözüm istiyoruz. Fikirler?

+0

http://stackoverflow.com/questions/7722062/google-oauth2-redirect-uri-with-several-parameters/26014587#26014587 benim cevap Teşekkür bakın! – Kiran

cevap

14

Parametrenin adı state (ve redirect_state değil)! google dokümanlarına göre

bir örnek OAuth isteği

olduğunu ->

https://accounts.google.com/o/oauth2/auth? 
scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile& 
state=%2Fprofile& 
redirect_uri=https%3A%2F%2Foauth2-login-demo.appspot.com%2Fcode& 
response_type=code& 
client_id=812741506391.apps.googleusercontent.com&approval_prompt=force 

State parametresi ve redirect_uri parametreyi unutmayınız. Bence ikisini karıştırdın.

DÜZENLEME - Bkz. Bu link Google. Durum parametreleri hakkında iyi bir açıklama ve web isteklerini oluşturma.

+5

Ah haklıydın. Muhtemelen bunun yerine erken uyumaya gitmiş olmalı! Teşekkürler – Henry

İlgili konular