मैं माइक्रोसॉफ्ट लाइव (.NET WebClient?) पर कैसे लॉग ऑन कर सकता हूं और बिंग विज्ञापन API कॉल करने के लिए टोकन प्राप्त करने के लिए OAuth प्रक्रिया को स्वचालित कर सकता हूं?बिंग विज्ञापन OAuth स्वचालन केवल .NET का उपयोग कर?
मेरा प्रश्न How do I get an OAuth request_token from live.com? के समान है। हालांकि, मैं एक अन्य विज्ञापन बिंग विज्ञापन खातों से जुड़ा हुआ एक बिंग विज्ञापन सुपर व्यवस्थापक खाते के संदर्भ का उपयोग कर एक हेडलेस विंडोज सेवा (सी #, .NET 4.5.2) बना रहा हूं। विचार प्रमाणीकरण करना है, ऑथ बिट्स प्राप्त करें, और फिर 3:00 बजे बिट्स का उपयोग करके कॉल करें। कुछ खाते "प्रतिस्पर्धा" करते हैं, उदाहरण के लिए समूह ए को समूह बी से डेटा नहीं दिखाना चाहिए, इसलिए एप्लिकेशन को हर किसी के लिए डेटा प्राप्त करना और उसे फ़िल्टर करना और इसे वितरित करना रात भर कई व्यवसायिक समस्याओं को हल करता है।
मुझे चिंतित है कि यदि लाइव अनुभव की समस्या है, या हमारे आवेदन किसी भी कारण से विस्तारित समय के लिए नीचे है, तो हमें डेटा फिर से प्राप्त करने के लिए मैन्युअल रूप से पुनः प्रमाणीकरण करना होगा। क्रेडेंशियल्स का रखरखाव और प्रबंधन अब अतिरिक्त ओवरहेड है (यह एक एंटरप्राइज़ पर्यावरण के लिए है) जो एक इंट्रानेट वेब साइट/पेज का रूप लेना होगा ताकि जूनियर/यूनिनेटेड लोगों को काम करने के लिए काम करने की अनुमति मिल सके (परीक्षण को भूलना न भूलें और प्रलेखन)। इसके विपरीत, Google उन समूहों के लिए महत्वपूर्ण जोड़े का उपयोग करने का विकल्प प्रदान करता है जिन्हें पूरी तरह से स्वचालित तरीके से काम करने की आवश्यकता होती है। ऐसा लगता है कि ट्विटर के OAuth2 कार्यान्वयन को GUI लॉगऑन के बिना स्वचालित किया जा सकता है। ऐसा लगता है कि अन्य बिंग सेवाएं (जैसे Translation) को वेब क्लाइंट के साथ भी स्वचालित किया जा सकता है।
मेरे पास पहले से ही माइक्रोसॉफ्ट खाता नाम और पासवर्ड है, और बिंग विज्ञापन ऐप जीयूआई में "local-mydomain.com" सेट का कॉलबैक यूआरएल है (और स्थानीय-mydomain.com के लिए एक HOSTS प्रविष्टि है)।
माइक्रोसॉफ्ट sample काम पर प्रतीत होता है, लेकिन यह एमएस वेब ब्राउज़र नियंत्रण को स्वचालित करता है, उम्मीद है कि उपयोगकर्ता जीयूआई में प्रमाण पत्र इनपुट करने के लिए, और फिर टोकन दिया जाता है। ऐसा करने के लिए उपयोगकर्ताओं को सुपर व्यवस्थापक खाता देना एक विकल्प नहीं है। डेटा अपलोड/डाउनलोड करने के लिए प्रमाणीकृत करने के लिए उपयोगकर्ता को 3:00 बजे उठने की अपेक्षा करना एक विकल्प नहीं है। किसी उपयोगकर्ता को खेत में किसी सर्वर पर "कुछ चलाने" के लिए डेस्कटॉप पहुंच प्राप्त करने की अपेक्षा करना एक विकल्प नहीं है।
सभी ओथ विचारों की सराहना की।
धन्यवाद।
partial class OAuthForm : Form
{
private static OAuthForm _form;
private static WebBrowser _browser;
private static string _code;
private static string _error;
// When you register your application, the Client ID is provisioned.
private const string ClientId = "000redacted000";
// Request-related URIs that you use to get an authorization code,
// access token, and refresh token.
private const string AuthorizeUri = "https://login.live.com/oauth20_authorize.srf";
private const string TokenUri = "https://login.live.com/oauth20_token.srf";
private const string DesktopUri = "https://login.live.com/oauth20_desktop.srf";
private const string RedirectPath = "/oauth20_desktop.srf";
private const string ConsentUriFormatter = "{0}?client_id={1}&scope=bingads.manage&response_type=code&redirect_uri={2}";
private const string AccessUriFormatter = "{0}?client_id={1}&code={2}&grant_type=authorization_code&redirect_uri={3}";
private const string RefreshUriFormatter = "{0}?client_id={1}&grant_type=refresh_token&redirect_uri={2}&refresh_token={3}";
// Constructor
public OAuthForm(string uri)
{
InitializeForm(uri);
}
[STAThread]
static void Main()
{
// Create the URI to get user consent. Returns the authorization
// code that is used to get an access token and refresh token.
var uri = string.Format(ConsentUriFormatter, AuthorizeUri, ClientId, DesktopUri);
_form = new OAuthForm(uri);
// The value for "uri" is
// https://login.live.com/oauth20_authorize.srf?client_id=000redacted000&scope=bingads.manage&response_type=code&redirect_uri=https://login.live.com/oauth20_desktop.srf
_form.FormClosing += form_FormClosing;
_form.Size = new Size(420, 580);
Application.EnableVisualStyles();
// Launch the form and make an initial request for user consent.
// For example POST /oauth20_authorize.srf?
// client_id=<ClientId>
// &scope=bingads.manage
// &response_type=code
// &redirect_uri=https://login.live.com/oauth20_desktop.srf HTTP/1.1
Application.Run(_form); // <!---------- Problem is here.
// I do not want a web browser window to show,
// I need to automate the part of the process where
// a user enters their name/password and are
// redirected.
// While the application is running, browser_Navigated filters traffic to identify
// the redirect URI. The redirect's query string will contain either the authorization
// code if the user consented or an error if the user declined.
// For example https://login.live.com/oauth20_desktop.srf?code=<code>
// If the user did not give consent or the application was
// not registered, the authorization code will be null.
if (string.IsNullOrEmpty(_code))
{
Console.WriteLine(_error);
return;
}
'माइक्रोसॉफ्ट नमूना काम करने के लिए प्रकट होता है, लेकिन यह एमएस वेब ब्राउज़र नियंत्रण को स्वचालित, उम्मीद इनपुट साख के लिए एक उपयोगकर्ता GUI' में आप उस कोड स्निपेट दिखाने शायद आप साख Enum गलत तरीके से करता है, तो एक है का उपयोग कर रहे सकते हैं आवश्यक .. – MethodMan
@DJKRAZE, समस्या एनम नहीं है, यह है कि एक टोकन प्राप्त करने के लिए एमएस नमूने में एक Winform + वेब ब्राउज़र नियंत्रण की आवश्यकता है। मेरे पास एक ऑथ टोकन प्राप्त करने के लिए रैक में बैठे सर्वर पर एक GUI COM ऑब्जेक्ट पॉप-अप नहीं हो सकता है। मेरी वास्तविक समस्या यह नहीं जानती है कि एक टोकन वापस पाने के लिए शुद्ध कोड में क्रेडेंशियल कैसे भेजना है - बिना जीयूआई के। धन्यवाद। – Snowy
क्या आप दिखा सकते हैं कि अब तक आपके पास क्या है .. यह सामान्य रूप से कठिन नहीं लगता है कि ज्यादातर टोकन या उपयोगकर्ता नाम \ डोमेन पासवर्ड का उपयोग करते हैं, उदाहरण के लिए 'PropertyName.UseDefaultCredentials' का प्रस्ताव है उदाहरण के लिए आप कोड – MethodMan