Hi guys,
We are trying to connect to a portal using Python API and we have got some issues with it. The use case here is that we want to authenticate non-interactive fashion to the portal using OAuth on times fashion. Basically we have followed this guide. When we run the code, we see following error:
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\arcgis\_impl\connection.py
in oauth_authenticate(self, client_id, expiration)
462 'username': self._username,
463 'password': self._password,
--> 464 'oauth_state': oauth_info['oauth_state']
465 }
466 content = self.post('oauth2/signin', parameters, ssl=True, try_json=False, add_token=False)
UnboundLocalError: local variable 'oauth_info' referenced before assignment
Code used:
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> GIS
gis <SPAN class="operator token">=</SPAN> GIS<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"https://{{portalurlhere}}/home"</SPAN><SPAN class="punctuation token">,</SPAN>
username<SPAN class="operator token">=</SPAN><SPAN class="string token">'{{usernamehere}}'</SPAN><SPAN class="punctuation token">,</SPAN>
password<SPAN class="operator token">=</SPAN><SPAN class="string token">'{{passwordhere}}'</SPAN><SPAN class="punctuation token">,</SPAN>
client_id<SPAN class="operator token">=</SPAN><SPAN class="string token">'{{clientidhere}}'</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Successfully logged in as: "</SPAN> <SPAN class="operator token">+</SPAN> gis<SPAN class="punctuation token">.</SPAN>properties<SPAN class="punctuation token">.</SPAN>user<SPAN class="punctuation token">.</SPAN>username<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Atma Mani Rohit Singh Any idea what we are doing wrong here? Do you think this is an issue in the API?