2011-04-13 17 views
7

मैं omniauth का उपयोग कर Google प्रमाण-पत्रों के साथ सफलतापूर्वक लॉगिन कर रहा हूं? omniauth ऊपर के लिंक का उपयोग करके नीचे दिए गए लिंकरेल 3 omniauth का उपयोग कर जीमेल संपर्क प्राप्त कर रहा है?

https://www.google.com/accounts/o8/id?id=xxxxxxxxxx

के रूप में यूआईडी प्रदान कर रहा है जीमेल संपर्कों को प्राप्त करने के लिए या अपने जीमेल संपर्क

उत्तर

5

नहीं है, Omniauth सिर्फ प्रमाणीकरण प्रदान करता है पाने के लिए किसी अन्य तरीके से संभव है। https://github.com/cardmagic/contacts

उद्धरण::

एक मणि है कि आप के लिए दिलचस्प हो सकता है नहीं है "संपर्क हॉटमेल, एओएल, जीमेल, Plaxo और याहू सहित विभिन्न प्रदाताओं से संपर्क सूची जानकारी हड़पने के लिए एक सार्वभौमिक इंटरफेस है।"

संपादित करें: इस ब्लॉग पोस्ट पर एक नज़र भी ले लो: http://rtdptech.com/2010/12/importing-gmail-contacts-list-to-rails-application/

5

here से अपने client_id और client_secret प्राप्त करें। यह एक मोटा लिपि है, जो पूरी तरह से ठीक काम करता है। इसे अपनी जरूरतों के अनुसार संशोधित करें।

require 'net/http' 
    require 'net/https' 
    require 'uri' 
    require 'rexml/document' 

    class ImportController < ApplicationController 

     def authenticate 
     @title = "Google Authetication" 

     client_id = "xxxxxxxxxxxxxx.apps.googleusercontent.com" 
     google_root_url = "https://accounts.google.com/o/oauth2/auth?state=profile&redirect_uri="+googleauth_url+"&response_type=code&client_id="+client_id.to_s+"&approval_prompt=force&scope=https://www.google.com/m8/feeds/" 
     redirect_to google_root_url 
     end 

     def authorise 
     begin 
      @title = "Google Authetication" 
      token = params[:code] 
      client_id = "xxxxxxxxxxxxxx.apps.googleusercontent.com" 
      client_secret = "xxxxxxxxxxxxxx" 
      uri = URI('https://accounts.google.com/o/oauth2/token') 
      http = Net::HTTP.new(uri.host, uri.port) 
      http.use_ssl = true 
      http.verify_mode = OpenSSL::SSL::VERIFY_NONE 
      request = Net::HTTP::Post.new(uri.request_uri) 

      request.set_form_data('code' => token, 'client_id' => client_id, 'client_secret' => client_secret, 'redirect_uri' => googleauth_url, 'grant_type' => 'authorization_code') 
      request.content_type = 'application/x-www-form-urlencoded' 
      response = http.request(request) 
      response.code 
      access_keys = ActiveSupport::JSON.decode(response.body) 

      uri = URI.parse("https://www.google.com/m8/feeds/contacts/default/full?oauth_token="+access_keys['access_token'].to_s+"&max-results=50000&alt=json") 

      http = Net::HTTP.new(uri.host, uri.port) 
      http.use_ssl = true 
      http.verify_mode = OpenSSL::SSL::VERIFY_NONE 
      request = Net::HTTP::Get.new(uri.request_uri) 
      response = http.request(request) 
      contacts = ActiveSupport::JSON.decode(response.body) 
      contacts['feed']['entry'].each_with_index do |contact,index| 

      name = contact['title']['$t'] 
      contact['gd$email'].to_a.each do |email| 
       email_address = email['address'] 
       Invite.create(:full_name => name, :email => email_address, :invite_source => "Gmail", :user_id => current_user.id) # for testing i m pushing it into database.. 
      end 

      end 
     rescue Exception => ex 
      ex.message 
     end 
     redirect_to root_path , :notice => "Invite or follow your Google contacts." 


     end 

    end 

सेटिंग्स के लिए स्क्रीनशॉट।

enter image description here

+0

MultiJson :: LoadError (795: ' पर अप्रत्याशित टोकन <मेटा http-समतुल्य = "सामग्री प्रकार" सामग्री = "text/html; charset = utf-8"> त्रुटि (ग्राहक त्रुटि) – <span class="text-secondary"> <small> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/497129/">baj</a></span> <span></span> </small> </span> </p> </div> </div> </div> </div> </div> </article> </div> <div class="clearfix"> </div> <div class="relative-box"> <div class="relative">संबंधित मुद्दे</div> <ul class="relative_list"> <li> 1. <a href="http://hi.voidcc.com/question/p-eojaailk-b.html" target="_blank" title="जीमेल संपर्क कैसे प्राप्त करें?"> जीमेल संपर्क कैसे प्राप्त करें? </a> </li> <li> 2. <a href="http://hi.voidcc.com/question/p-mmvjnmqe-h.html" target="_blank" title="रेल 3 रीसेट सत्र का उपयोग कर"> रेल 3 रीसेट सत्र का उपयोग कर </a> </li> <li> 3. <a href="http://hi.voidcc.com/question/p-redizesr-a.html" target="_blank" title="जीमेल संपर्क एपीआई"> जीमेल संपर्क एपीआई </a> </li> <li> 4. <a href="http://hi.voidcc.com/question/p-odemzuxd-m.html" target="_blank" title="जीमेल उपयोगकर्ता के संपर्क कैसे प्राप्त करें?"> जीमेल उपयोगकर्ता के संपर्क कैसे प्राप्त करें? </a> </li> <li> 5. <a href="http://hi.voidcc.com/question/p-vpnjhbip-s.html" target="_blank" title="आईओएस रेल 3 सर्वर और Omniauth"> आईओएस रेल 3 सर्वर और Omniauth </a> </li> <li> 6. <a href="http://hi.voidcc.com/question/p-gswzoxla-bk.html" target="_blank" title="का उपयोग कर प्राप्त कर रहा है मोड"> का उपयोग कर प्राप्त कर रहा है मोड </a> </li> <li> 7. <a href="http://hi.voidcc.com/question/p-remhmbat-h.html" target="_blank" title="LightOpenID का उपयोग कर Google संपर्क प्राप्त करना?"> LightOpenID का उपयोग कर Google संपर्क प्राप्त करना? </a> </li> <li> 8. <a href="http://hi.voidcc.com/question/p-adytcqgq-be.html" target="_blank" title="हमसे संपर्क करें रेल 3"> हमसे संपर्क करें रेल 3 </a> </li> <li> 9. <a href="http://hi.voidcc.com/question/p-rxockrxp-v.html" target="_blank" title="डेविस + Omniauth + fb_graph + रेल 3 ट्यूटोरियल"> डेविस + Omniauth + fb_graph + रेल 3 ट्यूटोरियल </a> </li> <li> 10. <a href="http://hi.voidcc.com/question/p-fdmibzhj-br.html" target="_blank" title="जीमेल का उपयोग कर रेल 3 पर तैयार होने की पुष्टि ईमेल"> जीमेल का उपयोग कर रेल 3 पर तैयार होने की पुष्टि ईमेल </a> </li> <li> 11. <a href="http://hi.voidcc.com/question/p-vyhclaws-w.html" target="_blank" title="ActivityNotFoundException संपर्क ContentProvider लोड करने का प्रयास कर रहा है?"> ActivityNotFoundException संपर्क ContentProvider लोड करने का प्रयास कर रहा है? </a> </li> <li> 12. <a href="http://hi.voidcc.com/question/p-hlfqqwme-y.html" target="_blank" title="जीमेल रेल से ईमेल भेजना 3"> जीमेल रेल से ईमेल भेजना 3 </a> </li> <li> 13. <a href="http://hi.voidcc.com/question/p-wswkfsco-k.html" target="_blank" title="रेल 3, सेट i18n लोकेल काम नहीं कर रहा है"> रेल 3, सेट i18n लोकेल काम नहीं कर रहा है </a> </li> <li> 14. <a href="http://hi.voidcc.com/question/p-awgohorb-r.html" target="_blank" title="रेलवे प्राप्त करना 3.1 है has_secure_password OmniAuth"> रेलवे प्राप्त करना 3.1 है has_secure_password OmniAuth </a> </li> <li> 15. <a href="http://hi.voidcc.com/question/p-yxxgsrdy-m.html" target="_blank" title="रेल के साथ जीमेल smtp 3"> रेल के साथ जीमेल smtp 3 </a> </li> <li> 16. <a href="http://hi.voidcc.com/question/p-qyerruqq-x.html" target="_blank" title="ब्लूक्लोथ रेल के साथ काम नहीं कर रहा है 3"> ब्लूक्लोथ रेल के साथ काम नहीं कर रहा है 3 </a> </li> <li> 17. <a href="http://hi.voidcc.com/question/p-effatnwv-br.html" target="_blank" title="प्राप्त कर रहा है नेमस्पेस"> प्राप्त कर रहा है नेमस्पेस </a> </li> <li> 18. <a href="http://hi.voidcc.com/question/p-wwacqubo-bk.html" target="_blank" title="बेहतर उपयोग कर उपयोग कर रहा है?"> बेहतर उपयोग कर उपयोग कर रहा है? </a> </li> <li> 19. <a href="http://hi.voidcc.com/question/p-kmazwvik-br.html" target="_blank" title="प्राप्त कर रहा है Powershell"> प्राप्त कर रहा है Powershell </a> </li> <li> 20. <a href="http://hi.voidcc.com/question/p-wjosqcmp-bs.html" target="_blank" title="रेल में जीमेल के माध्यम से संपर्क कैसे आयात करें?"> रेल में जीमेल के माध्यम से संपर्क कैसे आयात करें? </a> </li> <li> 21. <a href="http://hi.voidcc.com/question/p-yqbybbqy-br.html" target="_blank" title="मेरा .Net ऐप Verisign से संपर्क क्यों कर रहा है?"> मेरा .Net ऐप Verisign से संपर्क क्यों कर रहा है? </a> </li> <li> 22. <a href="http://hi.voidcc.com/question/p-axfocxpu-t.html" target="_blank" title="कॉलबैक जब मैं एक रेल 3 एप्लिकेशन में OmniAuth का उपयोग कर इस प्रक्रिया में प्रवेश आरंभ किया है, अगर मैं प्रदाता के पृष्ठ पर रद्द OmniAuth"> कॉलबैक जब मैं एक रेल 3 एप्लिकेशन में OmniAuth का उपयोग कर इस प्रक्रिया में प्रवेश आरंभ किया है, अगर मैं प्रदाता के पृष्ठ पर रद्द OmniAuth </a> </li> <li> 23. <a href="http://hi.voidcc.com/question/p-evezdvoi-r.html" target="_blank" title="रेल का उपयोग कर PostgreSQL में ग्रुप BY से कैसे संपर्क करें?"> रेल का उपयोग कर PostgreSQL में ग्रुप BY से कैसे संपर्क करें? </a> </li> <li> 24. <a href="http://hi.voidcc.com/question/p-xefgaurr-d.html" target="_blank" title="रेक स्पेक रेल पर्यावरण का उपयोग नहीं कर रहा"> रेक स्पेक रेल पर्यावरण का उपयोग नहीं कर रहा </a> </li> <li> 25. <a href="http://hi.voidcc.com/question/p-ztsisupn-w.html" target="_blank" title="पायथन और smtplib: oauth2 का उपयोग कर जीमेल के माध्यम से मेल भेज रहा है?"> पायथन और smtplib: oauth2 का उपयोग कर जीमेल के माध्यम से मेल भेज रहा है? </a> </li> <li> 26. <a href="http://hi.voidcc.com/question/p-bxfdiyjj-z.html" target="_blank" title="रेल सर्वर काम नहीं कर रहा है?"> रेल सर्वर काम नहीं कर रहा है? </a> </li> <li> 27. <a href="http://hi.voidcc.com/question/p-zpbggtby-q.html" target="_blank" title="रेल 3 मेलर काम नहीं कर रहा है और किसी भी त्रुटि को लॉगिंग नहीं कर रहा है"> रेल 3 मेलर काम नहीं कर रहा है और किसी भी त्रुटि को लॉगिंग नहीं कर रहा है </a> </li> <li> 28. <a href="http://hi.voidcc.com/question/p-gcbzjfgl-br.html" target="_blank" title="Model.reset_column_information मैं रेल 3.2 उपयोग कर रहा हूँ रेल प्रवास"> Model.reset_column_information मैं रेल 3.2 उपयोग कर रहा हूँ रेल प्रवास </a> </li> <li> 29. <a href="http://hi.voidcc.com/question/p-sktnuukv-bg.html" target="_blank" title="मैं google-api-javascript-client या "संपर्क API संस्करण 3.0" का उपयोग कर जीमेल से संपर्क कैसे आयात कर सकता हूं?"> मैं google-api-javascript-client या "संपर्क API संस्करण 3.0" का उपयोग कर जीमेल से संपर्क कैसे आयात कर सकता हूं? </a> </li> <li> 30. <a href="http://hi.voidcc.com/question/p-vtegpnaq-n.html" target="_blank" title="इस एचटीएमएल में 3 डी क्या कर रहा है?"> इस एचटीएमएल में 3 डी क्या कर रहा है? </a> </li> </ul> </div> <div> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-6208739752673518" data-ad-slot="3534119089"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div class="padding-top-10"></div> </div> </div> <script type="text/javascript" src="http://img2.voidcc.com/voidso/script/side.js?t=1652515422348"></script> <script type="text/javascript" src="http://img2.voidcc.com/voidso/plugin/highlight/highlight.pack.js"></script> <link href="http://img2.voidcc.com/voidso/plugin/highlight/styles/docco.css" media="screen" rel="stylesheet" type="text/css" /> <script type="text/javascript"> $('pre').each(function(i, e) { hljs.highlightBlock(e, "<span class='indent'> </span>", false) }); </script> <div class="col-lg-3 col-md-4 col-sm-5"> <div id="rightTop"> <div class="row"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- VOIDCC问答侧边栏广告 --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6208739752673518" data-ad-slot="3862022848" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div class="row sidebar panel panel-default"> <div class="panel-heading font-bold"> नवीनतम प्रश्न </div> <div class="m-b-sm m-t-sm clearfix"> <ul class="side_article_list"> <li class="side_article_list_item"> 1. <a href="http://hi.voidcc.com/question/p-abrbperv-bx.html" target="_blank" title="मैं System.Windows.Forms.Listbox पर सी # 7.0 टुपल प्रकार मानों का संग्रह कैसे बांध सकता हूं और डिस्प्ले सदस्य को तत्वों में से एक पर सेट कर सकता हूं?"> मैं System.Windows.Forms.Listbox पर सी # 7.0 टुपल प्रकार मानों का संग्रह कैसे बांध सकता हूं और डिस्प्ले सदस्य को तत्वों में से एक पर सेट कर सकता हूं? </a> </li> <li class="side_article_list_item"> 2. <a href="http://hi.voidcc.com/question/p-oxrwcbex-cg.html" target="_blank" title="अंत में वापसी क्यों अंततः खाली शब्दकोश देता है?"> अंत में वापसी क्यों अंततः खाली शब्दकोश देता है? </a> </li> <li class="side_article_list_item"> 3. <a href="http://hi.voidcc.com/question/p-glffjlsn-bw.html" target="_blank" title="पायथन - अगर यह बी"> पायथन - अगर यह बी </a> </li> <li class="side_article_list_item"> 4. <a href="http://hi.voidcc.com/question/p-uxwiusco-bw.html" target="_blank" title="अजवाइन प्रक्रिया 'कार्यकर्ता' शुरू करने से पहले '1 exitcode'"> अजवाइन प्रक्रिया 'कार्यकर्ता' शुरू करने से पहले '1 exitcode' </a> </li> <li class="side_article_list_item"> 5. <a href="http://hi.voidcc.com/question/p-wcwsmpnq-cp.html" target="_blank" title="मैं अब हाल ही में rxjs 5.5.2"> मैं अब हाल ही में rxjs 5.5.2 </a> </li> <li class="side_article_list_item"> 6. <a href="http://hi.voidcc.com/question/p-hitvsiro-bx.html" target="_blank" title="fscanf में "वर्णों की संख्या पढ़ने" की सीमा क्या है?"> fscanf में "वर्णों की संख्या पढ़ने" की सीमा क्या है? </a> </li> <li class="side_article_list_item"> 7. <a href="http://hi.voidcc.com/question/p-ezqwrjyh-cd.html" target="_blank" title="कई स्तंभ"> कई स्तंभ </a> </li> <li class="side_article_list_item"> 8. <a href="http://hi.voidcc.com/question/p-vprghlbn-ce.html" target="_blank" title="गणित परिचालनों का उपयोग कर फ़ाइलों का नाम बदलें"> गणित परिचालनों का उपयोग कर फ़ाइलों का नाम बदलें </a> </li> <li class="side_article_list_item"> 9. <a href="http://hi.voidcc.com/question/p-mpcpkmtj-bx.html" target="_blank" title="सी प्रोग्रामिंग में @ प्रतीक का उपयोग?"> सी प्रोग्रामिंग में @ प्रतीक का उपयोग? </a> </li> <li class="side_article_list_item"> 10. <a href="http://hi.voidcc.com/question/p-tfcbykxg-ce.html" target="_blank" title="'स्विफ्ट पैकेज जेनरेट-xcodeproj` के लिए मैकोज़ लक्ष्य सेट करें?"> 'स्विफ्ट पैकेज जेनरेट-xcodeproj` के लिए मैकोज़ लक्ष्य सेट करें? </a> </li> </ul> </div> </div> </div> <p class="article-nav-bar"></p> <div class="row sidebar article-nav"> <div class="row box_white visible-sm visible-md visible-lg margin-zero"> <div class="top"> <h3 class="title"><i class="glyphicon glyphicon-th-list"></i> संबंधित मुद्दे</h3> </div> <div class="article-relative-content"> <ul class="side_article_list"> <li class="side_article_list_item"> 1. <a href="http://hi.voidcc.com/question/p-eojaailk-b.html" target="_blank" title="जीमेल संपर्क कैसे प्राप्त करें?"> जीमेल संपर्क कैसे प्राप्त करें? </a> </li> <li class="side_article_list_item"> 2. <a href="http://hi.voidcc.com/question/p-mmvjnmqe-h.html" target="_blank" title="रेल 3 रीसेट सत्र का उपयोग कर"> रेल 3 रीसेट सत्र का उपयोग कर </a> </li> <li class="side_article_list_item"> 3. <a href="http://hi.voidcc.com/question/p-redizesr-a.html" target="_blank" title="जीमेल संपर्क एपीआई"> जीमेल संपर्क एपीआई </a> </li> <li class="side_article_list_item"> 4. <a href="http://hi.voidcc.com/question/p-odemzuxd-m.html" target="_blank" title="जीमेल उपयोगकर्ता के संपर्क कैसे प्राप्त करें?"> जीमेल उपयोगकर्ता के संपर्क कैसे प्राप्त करें? </a> </li> <li class="side_article_list_item"> 5. <a href="http://hi.voidcc.com/question/p-vpnjhbip-s.html" target="_blank" title="आईओएस रेल 3 सर्वर और Omniauth"> आईओएस रेल 3 सर्वर और Omniauth </a> </li> <li class="side_article_list_item"> 6. <a href="http://hi.voidcc.com/question/p-gswzoxla-bk.html" target="_blank" title="का उपयोग कर प्राप्त कर रहा है मोड"> का उपयोग कर प्राप्त कर रहा है मोड </a> </li> <li class="side_article_list_item"> 7. <a href="http://hi.voidcc.com/question/p-remhmbat-h.html" target="_blank" title="LightOpenID का उपयोग कर Google संपर्क प्राप्त करना?"> LightOpenID का उपयोग कर Google संपर्क प्राप्त करना? </a> </li> <li class="side_article_list_item"> 8. <a href="http://hi.voidcc.com/question/p-adytcqgq-be.html" target="_blank" title="हमसे संपर्क करें रेल 3"> हमसे संपर्क करें रेल 3 </a> </li> <li class="side_article_list_item"> 9. <a href="http://hi.voidcc.com/question/p-rxockrxp-v.html" target="_blank" title="डेविस + Omniauth + fb_graph + रेल 3 ट्यूटोरियल"> डेविस + Omniauth + fb_graph + रेल 3 ट्यूटोरियल </a> </li> <li class="side_article_list_item"> 10. <a href="http://hi.voidcc.com/question/p-fdmibzhj-br.html" target="_blank" title="जीमेल का उपयोग कर रेल 3 पर तैयार होने की पुष्टि ईमेल"> जीमेल का उपयोग कर रेल 3 पर तैयार होने की पुष्टि ईमेल </a> </li> </ul> </div> </div> </div> </div> </div> </div> </div><!-- wrap end--> <!-- footer --> <footer id="footer"> <div class="bg-simple lt"> <div class="container"> <div class="row padder-v m-t"> <div class="col-xs-8"> <ul class="list-inline"> <li><a href="http://hi.voidcc.com/contact">हमसे संपर्क करें</a></li> <li>© 2020 HI.VOIDCC.COM</li> <li><a rel="nofollow" href="https://beian.miit.gov.cn/" target="_blank">沪ICP备13005482号-13</a></li> <li><script type="text/javascript" src="https://s9.cnzz.com/z_stat.php?id=1280098168&web_id=1280098168"></script></li> <li><a href="http://cn.voidcc.com/" target="_blank" title="程序问答园区">简体中文</a></li> <li><a href="http://hk.voidcc.com/" target="_blank" title="程序問答園區">繁體中文</a></li> <li><a href="http://ru.voidcc.com/" target="_blank" title="поле вопросов и ответов">Русский</a></li> <li><a href="http://de.voidcc.com/" target="_blank" title="Frage - und - antwort - Park">Deutsch</a></li> <li><a href="http://es.voidcc.com/" target="_blank" title="Preguntas y respuestas">Español</a></li> <li><a href="http://hi.voidcc.com/" target="_blank" title="कार्यक्रम प्रश्न और उत्तर पार्क">हिन्दी</a></li> <li><a href="http://it.voidcc.com/" target="_blank" title="IL Programma di chiedere Park">Italiano</a></li> <li><a href="http://ja.voidcc.com/" target="_blank" title="プログラム問答園区">日本語</a></li> <li><a href="http://ko.voidcc.com/" target="_blank" title="프로그램 문답 단지">한국어</a></li> <li><a href="http://pl.voidcc.com/" target="_blank" title="program o park">Polski</a></li> <li><a href="http://tr.voidcc.com/" target="_blank" title="Program soru ve cevap parkı">Türkçe</a></li> <li><a href="http://vi.voidcc.com/" target="_blank" title="Đáp ứng viên">Tiếng Việt</a></li> <li><a href="http://fr.voidcc.com/" target="_blank" title="Programme interrogation Park">Française</a></li> </ul> </div> </div> </div> </div> </div> </footer> <!-- / footer --> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-77509369-5"></script> <script> window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag('js', new Date()); gtag('config', 'UA-77509369-5'); </script> <script> var _hmt = _hmt || []; (function () { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?67d4731349f0b00136755b80364ce381"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </body> </html>