2017-05-19 21 views
9

मैं गूगल एपीआई Oauth से यह संदेश मिल रहा हूँ: ग्राहक के लिए मान्य नहीं है मूल:मान्य नहीं है मूल

idpiframe_initialization_failed ", विवरण":। http://127.0.0 ... itelist इस

http://127.0.0.1:8887/

0: अपनी परियोजना के ग्राहक आईडी

मैं इस स्थानीय पथ से एक अनुरोध भेजने के लिए कोशिश कर रहा हूँ

के लिए मूल

और मैं पहले से ही अधिकृत जावास्क्रिप्ट मूल अनुभाग के लिए इस URL कहा: enter image description here

यह मेरा कोड है:

<!-- The top of file index.html --> 
<html itemscope itemtype="http://schema.org/Article"> 
<head> 
    <!-- BEGIN Pre-requisites --> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"> 
    </script> 
    <script src="https://apis.google.com/js/client:platform.js?onload=start" async defer> 
    </script> 
    <!-- END Pre-requisites --> 

<!-- Continuing the <head> section --> 
    <script> 
    function start() { 
     gapi.load('auth2', function() { 
     auth2 = gapi.auth2.init({ 
      client_id: 'MY CLIENT ID.apps.googleusercontent.com', 
      // Scopes to request in addition to 'profile' and 'email' 
      //scope: 'https://www.google.com/m8/feeds/' 
     }); 
     }); 
    } 
    </script> 




</head> 
<body> 


<button id="signinButton">Sign in with Google</button> 
<script> 
    $('#signinButton').click(function() { 
    // signInCallback defined in step 6. 
    auth2.grantOfflineAccess().then(signInCallback); 
    }); 
</script> 



<!-- Last part of BODY element in file index.html --> 
<script> 
function signInCallback(authResult) { 
    if (authResult['code']) { 

    // Hide the sign-in button now that the user is authorized, for example: 
    $('#signinButton').attr('style', 'display: none'); 

    // Send the code to the server 
    $.ajax({ 
     type: 'POST', 
     url: 'http://example.com/storeauthcode', 
     // Always include an `X-Requested-With` header in every AJAX request, 
     // to protect against CSRF attacks. 
     headers: { 
     'X-Requested-With': 'XMLHttpRequest' 
     }, 
     contentType: 'application/octet-stream; charset=utf-8', 
     success: function(result) { 
     // Handle or verify the server response. 
     }, 
     processData: false, 
     data: authResult['code'] 
    }); 
    } else { 
    // There was an error. 
    } 
} 
</script> 
    <!-- ... --> 
</body> 
</html> 

मैं इसे कैसे ठीक कर सकते हैं?

+0

[Google एपीआई प्रमाणीकरण: क्लाइंट के लिए मान्य मूल नहीं] का संभावित डुप्लिकेट (http://stackoverflow.com/questions/42566296/google-api-authentication-not-valid-origin-for-the-client) – DaImTo

+1

मैं अभी एक ही मुद्दे की उम्मीद कर रहा हूं। – Praytic

+0

क्या आप इसे ठीक करने में सक्षम थे? – Praytic

उत्तर

3

यदि यह आप के लिए सभी एक ही है, बजाय अपने अधिकृत जावास्क्रिप्ट मूल के http://localhost:8887 जोड़ने का प्रयास करें। अगर वह किसी बिंदु पर खुद को त्रुटि करता था और यह तय करता था। पता है कि तुम हालांकि यह http://127.0.0.1:8887/ करने के लिए अनुवाद अच्छी तरह से घटना के रूप में आपके अनुरोध के लिए इस URL का उपयोग करना होगा।

+0

आप यह कैसे करते हैं? – BradLaney

16

मैं तुम्हारा काफ़ी मिलती-जुलती समस्या हुई। मैंने localhost से कई श्वेतसूची वाले बंदरगाहों को जोड़ने की कोशिश की और कुछ भी काम नहीं कर रहा था। प्रमाण पत्र हटाने और उन्हें फिर से स्थापित करने के समाप्त हो गया। मेरे सेटअप के लिए googles अंत पर एक बग होना चाहिए।

+0

LOL यह काम किया ... इस समाधान के लिए इतना पहले भी कई Google API मुद्दों ... निश्चित रूप से यह एक याद रखने की आवश्यकता किया गया है। (wtf google ???) –

+0

आरओएफएल ने काम किया .. !! गूगल एपीआई – Ritesh

+0

यूप में ऐसी गूंगा त्रुटि, केवल एक चीज जो मेरे लिए भी काम करती है। यह कम से कम एक साल के लिए एक मुद्दा रहा है। क्या चल रहा है? –

0

मैं वेब पर कई स्थानों पर पढ़ता हूं जो इसे काम करने के लिए प्रमाण-पत्रों के निर्माण को फिर से करने के लिए उपयोग करते हैं।
तो मैंने किया, मैं एक ही परियोजना के लिए एक नया क्रेडेंशियल बनाया है और अपने नए उपयोगकर्ता के आईडी का इस्तेमाल किया और यह पूरी तरह से काम किया ... लगता श्वेत सूची के संस्करण की तरह एक सा flacky है ...

एनबी: मैंने स्थानीयहोस्ट127.0.0.1 के बजाय भी उपयोग किया, आईपी मान्य नहीं हैं।

संबंधित मुद्दे