ArcGIS Runtime 100.8 & Oauth2

494
0
07-20-2020 06:58 AM
MassimilianoGeppi
Esri Contributor

Hi

I'm trying to use the following example, about oauth2 authentication

https://developers.arcgis.com/net/latest/wpf/sample-code/authenticate-with-oauth/

running this example without changes and after pop-up authentication, i can see every items that i've published

inside my webmap (basemap + a portal feature layer) in a private user and group defined for, when it was created the "application"

OK

I read that should be possible, to use a Client Secret and change this type of authentication.

I would like to establish an authentication and authorization in background, by code, without an user interaction.

Every one could me suggest, which line should be modified on code in the example, to make it?

I've try to change the code in this way


      // If a client secret has been configured, set the authentication type to OAuthAuthorizationCode.
      if (!String.IsNullOrEmpty(ClientSecret))
      {
        // Use OAuthAuthorizationCode if you need a refresh token (and have specified a valid client secret).
        serverInfo.TokenAuthenticationType = TokenAuthenticationType.OAuthClientCredentials;
        serverInfo.OAuthClientInfo.ClientSecret = ClientSecret;
      }

but, when i run the example, i see my webmap with the selected basemap but my feature service it doesn't appear.

In the CreateCredentialAsync method, when "CredentialRequestInfo" is for my "Feature Layer" invoked  i see that the token generated its already expired and i don'n know why, maybe this could be the problem, how to solve?

I hope my problem it was well explained.

Thank you id advance.

M

0 Replies