Authorizing and Installing an app


#1

Hi there,
I'm using to authorizing the Microsoft.Owin Framework, I have the startups below

public void Configuration(IAppBuilder app)
    {
        app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

        app.UseCookieAuthentication(new CookieAuthenticationOptions());
        app.UseOpenIdConnectAuthentication(
        new OpenIdConnectAuthenticationOptions
        {
            ClientId = clientId,
            Authority = "https://app.hubspot.com/oauth/authorize",
            RedirectUri = "https://fdca9807.ngrok.io/api/HubSpot/HandlerNotification",
            PostLogoutRedirectUri = redirectUri,
            Scope = "contacts automation",
            ResponseType = "id_token token",
            TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters() {  ValidateIssuer = false },
            Notifications = new OpenIdConnectAuthenticationNotifications
            {
                AuthenticationFailed = OnAuthenticationFailed
            }

        }
        );
        
    }

But when I try to connect using "GetOwinContext"

HttpContext.GetOwinContext().Authentication.Challenge(
                new AuthenticationProperties { RedirectUri = "/" },
                OpenIdConnectAuthenticationDefaults.AuthenticationType);

Always got the following exception

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

Please can you help on this?
Many thanks.


#2

Hi @fjpampliega,

I'm not particularly familiar with the Microsoft Owin framework, but that error seems to indication that there was an issue parsing JSON; is it possible that you expect to get JSON somewhere but are actually receiving something else? For example, is it possible that you're passing a file path to a method that takes a JSON string?

The error doesn't appear to be specifically related to the HubSpot APIs, but here are some stack overflow topics that have similar errors: