Wiki

Clone wiki

Etz.Api / Auth0 Tokens

#Auth0 Tokens#

Note: Before you can create a token you will need an Auth0 Client Id and Audience. Please contact Support at support@etztec.com to receive this.

In order to access our API, you will need a valid Auth0 token.

Sample code for .NET can be found in the source code here.

Below are snippets of the main part of the code that makes the request to Auth0 and returns a token id string.

Sample C# code

#!c#

using Auth0.AuthenticationApi;
using Auth0.AuthenticationApi.Models;

namespace Auth0WinFormsTest
{
public class TokenProvider
{
  public string GetToken(string userName, string password)
  {
    var domain = Properties.Settings.Default.Auth0Domain;
    var client = Properties.Settings.Default.Auth0ClientID;
    var audience = Properties.Settings.Default.Auth0Audience;

        // Sign into Auth0
        var auth0Client = new AuthenticationApiClient(domain);
        var requestOptions = new ResourceOwnerTokenRequest
        {
            ClientId = client,
            Username = userName,
            Password = password,
            Audience = audience
        };

        var result = auth0Client.GetTokenAsync(requestOptions).Result;
        return result.AccessToken;
    }
  }
}

The GetToken method would return a valid token that you can use to call operations on the Etz API.

Updated