8

पर अपना प्रमाणीकरण नहीं बढ़ा रहा है मैंने का उपयोग करने के लिए console.developers.google.com में एक प्रोजेक्ट बनाया है। वहां हमें क्रेडेंशियल उत्पन्न करने और आवेदन प्रकारGoogle कैलेंडर एपीआई स्थानीय रूप से ठीक काम कर रहा है लेकिन सर्वर

स्थानीयहोस्ट और अनुप्रयोग प्रकार other के लिए Json है जो ठीक काम करता है। जैसा कि नीचे दिखाया

{ 
    "installed": { 
    "client_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com", 
    "project_id": "xxxxxx-00000", 
    "auth_uri": "https://accounts.google.com/o/oauth2/auth", 
    "token_uri": "https://accounts.google.com/o/oauth2/token", 
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", 
    "client_secret": "xxxxxxxxxxxx", 
    "redirect_uris": [ "urn:ietf:wg:oauth:2.0:oob", "http://localhost" ] 
    } 
} 

और सर्वर कुछ मानकों के आधार पर मेजबान के लिए आवेदन प्रकार Web Application के लिए Json में विभिन्न मूल्यों है।

{ 
    "web": { 
    "client_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com", 
    "project_id": "xxxxxxxx-99999", 
    "auth_uri": "https://accounts.google.com/o/oauth2/auth", 
    "token_uri": "https://accounts.google.com/o/oauth2/token", 
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", 
    "client_secret": "xxxxxxxxxxxxxxxxxxxxxxx", 
    "redirect_uris": [ "http://demo.mydemo.com" ], 
    "javascript_origins": [ "http://demo.mydemo.com" ] 
    } 
} 
यहाँ

उपयोगकर्ता (केवल जो लोग गूगल कैलेंडर को एकीकृत किया है) एक घटना गूगल का उपयोग करें और पुनः निर्देशित पृष्ठ पर रीडायरेक्ट करने से पहले व्यक्तिगत डेटा को पढ़ने के लिए पूछने के लिए जो गूगल खाते की सहमति लेना चाहिए बनाने के लिए प्रयास करते हैं। सहमति देने पर यह चयनित Google खाते के कैलेंडर में प्रदत्त डेटा जोड़ देगा। समस्या यह है कि यह उपयोगकर्ता को Oauth प्रमाणीकरण यानी The Consent Screen पर पुनर्निर्देशित नहीं कर रहा है।

Image Of Consent Screen क्या कोई मुझे इस मुद्दे को हल करने में मदद कर सकता है? इस प्रकार

System.AggregateException: One or more errors occurred. ---> System.NotSupportedException: Failed to launch browser with "https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&response_type=code&client_id=xxxxxxxxxxxx-vqi4faduqgcpt3d2ruv53ltgr0rkgfsb.apps.googleusercontent.com&redirect_uri=http:%2F%2Flocalhost:53998%2Fauthorize%2F&scope=https:%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar" for authorization. See inner exception for details. ---> System.ComponentModel.Win32Exception: Access is denied 
    at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) 
    at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) 
    at Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.<ReceiveCodeAsync>d__8.MoveNext() 
    --- End of inner exception stack trace --- 
    at Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.<ReceiveCodeAsync>d__8.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() 
    at Google.Apis.Auth.OAuth2.AuthorizationCodeInstalledApp.<AuthorizeAsync>d__8.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.<AuthorizeAsync>d__4.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.<AuthorizeAsync>d__1.MoveNext() 
    --- End of inner exception stack trace --- 
    at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) 
    at KriyaCRM.Controllers.ActivitiesController.GetCalendarConnection(Activities objact, String Operation) 
---> (Inner Exception #0) System.NotSupportedException: Failed to launch browser with "https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&response_type=code&client_id=430760523223-vqi4faduqgcpt3d2ruv53ltgr0rkgfsb.apps.googleusercontent.com&redirect_uri=http:%2F%2Flocalhost:53998%2Fauthorize%2F&scope=https:%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar" for authorization. See inner exception for details. ---> System.ComponentModel.Win32Exception: Access is denied 
    at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) 
    at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) 
    at Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.<ReceiveCodeAsync>d__8.MoveNext() 
    --- End of inner exception stack trace --- 
    at Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.<ReceiveCodeAsync>d__8.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() 
    at Google.Apis.Auth.OAuth2.AuthorizationCodeInstalledApp.<AuthorizeAsync>d__8.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.<AuthorizeAsync>d__4.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.<AuthorizeAsync>d__1.MoveNext()<--- 
+1

"यह मुझे रीडायरेक्ट नहीं कर रहा है" का क्या मतलब है - कौन रीडायरेक्ट नहीं कर रहा है? कृपया अपने कोड सहित, आप जो भी कर रहे हैं, उसके बारे में अधिक जानकारी प्रदान करें। –

+0

मैंने प्रश्न अपडेट किया है। यदि आपको अभी भी भ्रम है तो आप पूछ सकते हैं। धन्यवाद – Divya

+0

ठीक है, तो साइन इन करते समय वास्तव में * क्या हो रहा है? क्या यह कहीं और रीडायरेक्ट कर रहा है? प्रतिक्रिया कैसी दिखती है? –

उत्तर

0
var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, 
                      scopes, 
                      userName, 
                      CancellationToken.None, 
                      new FileDataStore(credPath, true)).Result; 

स्थापित अनुप्रयोगों के लिए किया जाता है

त्रुटि है। जब आप डीबग मोड में अपना कोड चला रहे हों तो यह शायद काम करेगा क्योंकि आपके पास अपनी स्थानीय मशीन पर एक वेब ब्राउज़र खोलने की पहुंच है। हालांकि जब आप इसे किसी सर्वर पर होस्ट करने का प्रयास करते हैं तो यह काम नहीं करेगा क्योंकि आपके पास सर्वर पर एक वेब ब्राउज़र खोलने की पहुंच नहीं है जिसे आप करना चाहते हैं, क्लाइंट मशीन पर एक वेब ब्राउज़र खोलना है।

private static readonly IAuthorizationCodeFlow flow = 
      new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer 
       { 
        ClientSecrets = new ClientSecrets 
        { 
         ClientId = "PUT_CLIENT_ID_HERE", 
         ClientSecret = "PUT_CLIENT_SECRET_HERE" 
        }, 
        Scopes = new[] { DriveService.Scope.Drive }, 
        DataStore = new FileDataStore("Drive.Api.Auth.Store") 
       }); 

आपको इस आलेख का पालन करने का प्रयास करना चाहिए। Google Oauth2 asp.net MVC

+0

मैं इस कोशिश की, लेकिन यह जब हम स्थानीय यानी के लिए 'इसका इस्तेमाल के रूप में काम नहीं कर रहा वर क्रेडेंशियल = GoogleWebAuthorizationBroker.AuthorizeAsync (GoogleClientSecrets.Load (धारा) .Secrets, स्कोप, उपयोगकर्ता नाम, CancellationToken.None, नई FileDataStore (क्रेडिटपाथ, सच))।नतीजा; 'यह एक टोकन – Divya

+0

देता है और इसके साथ हम किसी भी घटनाक्रम को जोड़/संशोधित कर सकते हैं लेकिन 'IAuthorizationCodeFlow' इसे प्रदान नहीं करते हैं। तो मैं इस बिंदु पर अटक गया हूँ। जोड़ने के लिए और क्या चाहिए। निश्चित रूप से कुछ याद आ रही है – Divya

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