<\/HEAD>
J'essaie d'obtenir un token pour ArcGIS Online en utilisant c# (en fait, plus précisément SSIS). J'ai une URL que je peux utiliser et qui fonctionne bien, et je peux y accéder et obtenir ce dont j'ai besoin dans Chrome, mais cela ne fonctionne pas via c# en utilisant un WebClient.<\/P>
<\/P>
Je peux obtenir d'autres jsons via SSIS\/C# WebClient, mais PAS ArcGIS Online pour une raison quelconque. L'URL fonctionne via Chrome, mais ne renvoie pas de réponse via SSIS\/C# WebClient.<\/P>
Mon code (avec client id\/secret\/credentials) est :<\/P>
<SPAN class="" style="color: #101094; border: 0px; font-weight: inherit; font-size: 13px;">string<\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> webResource <\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">=<\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> <\/SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: 13px;">"https:\/\/mymaps.maps.arcgis.com\/sharing\/rest\/oauth2\/token?client_id=MYCLIENTID&client_secret=MYCLIENTSECRET&grant_type=client_credentials"<\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">;<\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"><\/SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;">WebClient<\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> wc <\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">=<\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> <\/SPAN><SPAN class="" style="color: #101094; border: 0px; font-weight: inherit; font-size: 13px;">new<\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> <\/SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;">WebClient<\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">();<\/SPAN><SPAN class="" style="color:#303336;border-width :0;font-weight :inherit;font-size :13px"><\/SPAN><SPAN class="" style="color:#101094;border-width :0;font-weight :inherit;font-size :13px">string<\/SPAN><SPAN class="" style="color:#303336;border-width :0;font-weight :inherit;font-size :13px"> json <\/SPAN><SPAN class="" style="color:#303336;border-width :0;font-weight :inherit;font-size :13px">=<\/SPAN><SPAN class="" style="color:#303336;border-width :0;font-weight :inherit;font-size :13px"> wc<\/SPAN><SPAN class="" style="color:#303336;border-width :0;font-weight :inherit;font-size :13px">.<\/SPAN><SPAN class="" style="color:#2b91af;border-width :0;font-weight :inherit;font-size :13px">DownloadString<\/SPAN><SPAN class="" style="color:#303336;border-width :0;font-weight :inherit;font-size :13px">(<\/SPAN><SPAN class="" style="color:#303336;border-width :0;font-weight :inherit;font-size :13px">webResource<\/SPAN><SPAN class="" style="color:#303336;border-width :0;font-weight :inherit;font-size :13px">);\n<\/SPAN><\/CODE><\/PRE><P style="color:#242729;background-color:#f9f8f6;border-width :0;margin :0 0 .5em .5em ">Je parserais ensuite le json.<\/P><P style = " color:#242729;background-color:#f9f8f6;border-width :0;margin-bottom :.5em ">Actuellement, j'obtiens:<\/P><BLOCKQUOTE class = "jive_macro_quote jive-quote jive_text_macro"><P ><CODE ><SPAN class = " " style = " color:#303336;border-width :0;font-weight :inherit;font-size :13px ">DTS <\/SPAN ><SPAN class = " " style = " color:#2b91af;border-width :0;font-weight :inherit;font-size :13px ">Script<\/SPAN ><SPAN class = " " style = " color:#303336;border-width :0;font-weight :inherit;font-size :13px "> <\/SPAN ><SPAN class = " " style = " color:#2b91af;border-width :0;font-weight :inherit;font-size :13px ">Task<\/SPAN ><SPAN class = " " style = " color:#303336;border-width :0;font-weight :inherit;font-size :13px "> a rencontré une exception <\/SPAN ><SPAN class = " " style = " color:#101094;border-width :0;font-weight :inherit;font-size :13px ">dans<\/SPAN ><SPAN class = " " style = " color:#303336;border-width :0;font-weight :inherit;font-size :13px "> le code utilisateur<\/SPAN ><SPAN class = " " style = " color:#303336;border-width :0;font-weight :inherit;font-size :13px ">:<\/SPAN ><SPAN class = " " style = " color:#303336;border-width :0;font-weight :inherit;font-size :13px "> nom du projet<\/SPAN ><SPAN class = " " style = " color:#303336;border-width :0;font-weight :inherit;font-size :13px ">:<\/SPAN ><SPAN class = " " style = " color:#303336;border-width :0;font-weight :inherit;font-size :13px "> ST_0a306cf2e1634509bea49b75b7d93265 <\/SPAN ><SPAN class = " " style = " color:#2b91af;border-width :0;font-weight :inherit;font-size :13px ">Exception<\/SPAN ><SPAN class = " " style = " color:#303336;border-width :0;font-weight :inherit;font-size :13px "> a été levée <\/SPAN ><SPAN class = " " style = " color:#101094;border-width :0;font-weight :inherit;font-size :13px ">par<\/SPAN ><SPAN class = " " style = " color:#303336;border-width :0;font-weight :inherit;font-size :13px "> la cible d'une invocation<\/SPAN ><SPAN class = " " style = " color:#303336;border-width :0;font-weight :inherit;font-size :13px ">.<\/SPAN ><span class=\"\"style=\"color:#303336;border-width:none !important;;font-family:"";font-style:none !important;;font-variant:none !important;;font-stretch:none !important;;font-kerning:none !important;;font-feature-settings:none !important;;font-language-override:none !important;;text-decoration:none !important;;vertical-align:none !important;;white-space:none !important;;word-spacing:none !important;;letter-spacing:none !important;;line-height:none !important;;text-indent:none !important;;text-transform:none !important;;unicode-bidi:none !important;;direction:ltr !important\"> à <spanclass=\"\"style=\"color:#2b91af\">System</span>.<spanclass=\"\"style=\"color:#303336\">.</span>RuntimeMethodHandle.<spanclass=\"\"style=\"color:#2b91af\">InvokeMethod</span>(<spanclass=\"\"style=\"color:#303336\">(</span>Object<spanclass=\"\"style=\"color:#2b91af\"> target</span>, Object[] arguments, Signature sig, Boolean constructor)<spanclass=\"\"style=\"color:#303336\">)</span> à <spanclass=\"\"style=\"color:#2b91af\">System</span>.<spanclass=\"\"style=\"color:#303336\">.</span>Reflection.<spanclass=\"\"style=\"color:#2b91af\">RuntimeMethodInfo</span>.<spanclass=\"\"style=\"color:#303336\">.</span>UnsafeInvokeInternal(<spanclass=\"\"style=\"color:#2b91af\">Object</span> obj, Object[] parameters, Object[] #303336; border: 0px; font-weight: inherit; font-size: 13px;"> arguments</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">)</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> à </SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;">System</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">.</SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;">Reflection</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">.</SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;">RuntimeMethodInfo</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">.</SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;">Invoke</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">(</SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;">Object</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> obj</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">,</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;">BindingFlags</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> invokeAttr</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">,</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;">Binder</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> binder</SPAN><SPAN class="" style="color:#303336;border:none;font-weight:auto;font-size=13px">,</span><span class='' style='color:#2b91af;border:none;font-weight:auto;font-size=13px'>Object</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'>[] parameters</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'>,</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'> </span><span class='' style='color:#2b91af;border:none;font-weight:auto;font-size=13px'>CultureInfo</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'> culture)</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'> à </span><span class='' style='color:#2b91af;border:none;font-weight:auto;font-size=13px'>System</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'>.</span><span class='' style='color:#2b91af;border:none;font-weight:auto;font-size=13px'>RuntimeType</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'>.</span><span class='' style='color:#2b91af;border:none;font-weight:auto;font-size=13px'>InvokeMember</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'>(</span><span class='' style='color:#2b91af;border:none;font-weight:auto;font-size=13px'>String</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'> name</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'>,</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'> </span><span class='' style='color:#2b91af;border:none;font-weight:auto;font-size=13px'>BindingFlags</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'> bindingFlags</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'>,</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'> </span><span class='' style='color:#2b91af;border:none;font-weight:auto;font-size=13px'>Binder</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'> binder</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'>,</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'> </span><span class='' style='color:#2b91af;border:none;font-weight:auto;font-size=13px'>Object</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'> target</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'>,</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'> </span><span class='' style='color:#2b91af;border:none;font-weight:auto;font-size=13px'>Object</span><span class='' style='color:#303336;border:none,font-weight:auto,font-size=13px'>[] providedArgs</span><span class='' style='color:#303336;border:none;font-weight:auto;font-size=13px'>,</span><span class='' style='color:#303336;border:none,font-weight:auto,font-size=13px'> </span><span class='' style='color:#2b91af;border:none,font-weight:auto,font-size=13px'>ParameterModifier</span><span class='' style='color:#303336;border:none,font-weight:auto,font-size=13px'>[] modifiers</span><span class='' style='color:#303336;border:none,font-weight:auto,font-size=13px'>,</span><span class='' style='color:#303336;border:none,font-weight:auto,font-size=13px'> </span><span class='' style='color:#2b91af;border:none,font-weight:auto,font-size=13px'>CultureInfo</span><span class='' style='color:#303336;border:none,font-weight:auto,font-size=13px'> culture</span><span class='' style='color:#303336;border:none,font-weight:auto,font-size=13px'>,</span><span class='' style='color:#303336;border:none,font-weight:auto,font-size=13px'> </span><span class='' style='color:#2b91af;border:none,font-weight:auto,font-size=13px'>String</span><span class='' style='color:#303336;border:none,font-weight:auto,font-size=13px'>[] namedParams)</span><span class='' style='border:none;margin-bottom:.5em;'> à </ span >< spanclass = " "style = " color :#2 b91 af ;border : none ;font - weight : auto ;font - size : 1 em ; " > Microsoft < / span >< spanclass = " "style = " color :#3 b33 af ;border : none ;font - weight : auto ;font - size :1 em ; " > . < / span >< spanclass = " "style = " color :#3 b33 af ;border : none ;font - weight : auto ;font - size :1 em ; " > SqlServer < / span >< spanclass = " "style = " color :#3 b33 af ;border : none ;font - weight : auto ;font - size :1 em ; " > . < / span >< spanclass = " "style = " color :#3 b33 af ;border : none ;font - weight : auto ;font - size :1 em ; " > Dts < / span >< spanclass = " "style = " color :#3 b33 af ;border : none ;font - weight : auto ;font - size :1 em ; " > . < / span >< spanclass = " "style = " color :#3 b33 af ;border : none ;font - weight : auto ;font - size :1 em ; " > Tasks < / span >< spanclass = " "style = " color :#3 b33 af ;border : none ;font - weight : auto ;font - size :1 em ; " > . < / span >< spanclass = " "style = " color :#3 b33 af ;border : none ;font - weight : auto ;font - size :1 em ; " > ScriptTask < / span >< spanclass = " "style = " color :#3 b33 af ;border : none ;font - weight : auto ;font - size :1 em ; " > . < / span >< spanclass = " "style = " color :#3 b33 af ;border : none ;font - weight : auto ;font - size :1 em ; " > VSTATaskScriptingEngine < / span >< spanclass = " "style = " color :#3 b33 af ;border : none ;font - weight : auto ;font - size :1 em ; " > . < / span >< spanclass = " "style = " color :#3 b33 af ;border : none ;font - weight : auto ;font - size :1 em ; " > ExecuteScript < / span >< spanclass = ""style ="border-none;margin-bottom:.5em;">( )< / code >< / p >< / blockquote >< pstyle ="border-0;margin-0-0-1em;">< br /> J'ai créé une application, comme décrit dans< SPAN > < / SPAN >< A href ="https://developers.arcgis.com/labs/rest/get-an-access-token/" rel ="nofollow noreferrer noopener" sty le ="couleur #1d4d5c bordure 0 px poids de la police hériter texte-décoration souligné marge 0 px " target ="_blank">https://developers.arcgis.com/labs/rest/get-an-access-token/ < / a ></p> <pstyle ="border-0;margin-0-0-1em;">< br /> Un exemple du json retourné (via Chrome) est :</p> <blockquoteclass ="jive_macro_quote jive-quote jive_text_macro"><p> <code> {<br> "access_token":<br> "blahblahblahcrazywords.."<br> border: 0px; font-weight: inherit; font-size: 13px;">,</SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: 13px;">"expires_in"</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">:</SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: 13px;">7200</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">}</SPAN>