What does "V1_ERROR - service.not_authorized: Not Authorized." mean for .Net SquareApi.OAuthApi.ObtainToken()

I have finally jumped through all the hoops and I’m ready to make a call to the Square API to obtain the coveted access_token.

ObtainTokenRequest TokenReq = new ObtainTokenRequest.Builder(ApplicationId, Secret, "authorization_code")
    .Code(Code)
    .Build();
try
{
    ObtainTokenResponse TokenResp = SquareApi.OAuthApi.ObtainToken(TokenReq);
}
catch (ApiException Ex)
{
    string Errors = string.Empty;
    foreach (Error Err in Ex.Errors)
    {
        Errors += string.Format("{0} - {1}: {2}{3}. ",
            Err.Category,
            Err.Code,
            Err.Detail,
            (Err.Field != null && Err.Field.Length > 0 ? string.Format(" ({0})", Err.Field) : string.Empty));
    }
    Response.Write(Errors);
}

This is throwing an ApiException of V1_ERROR - service.not_authorized: Not Authorized., I’m not really sure what to do with it, what is it telling me? I’ve double checked the values of my sandbox access tokey, application id and secret.

Thanks,
Russ

What’s your sandbox application ID? We can see what’s failing on our side in logs; we also have a separate, ongoing workstream to improve the OAuth errors, so that you get more descriptive errors in the future.

Here is my sandbox application id: sandbox - sq0idb - 5tdxJb07W00p1bceSNSPeA. I wasn’t sure if it was a good idea or not to include it in the sample code.

Looked in the logs - the error on our end was that your Application Secret was wrong.

Yup, I re-copied it and now it is working, thanks.