I'm trying to use `.IdentityApi.DeleteIdentity` AP...
# ory-network
j
I'm trying to use
.IdentityApi.DeleteIdentity
API, but keep getting 401. I use exactly the same token to access identity data and it works fine. Any ideas what's wrong?
p
Hi @jolly-tiger-57705 It's hard to say, are you passing in the project API key to this request?
j
Yes, I'm passing the API key. Client is initialized once and works fine when downloading data.
I'm using the go library
Copy code
tr := &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: config.IsDevelopment},
	}
	httpClient := &http.Client{Transport: tr}

	cfg := &kratos.Configuration{
		HTTPClient: httpClient,
		DefaultHeader: map[string]string{
			"Authorization": "Bearer:" + config.KratosToken,
			"Origin":        config.KratosOrigin,
		},
		UserAgent: "zamianeo-srv",
		Debug:     false,
		Servers: kratos.ServerConfigurations{
			{
				URL:         config.KratosUrl,
				Description: "Kratos URL from the",
			},
		},
		OperationServers: map[string]kratos.ServerConfigurations{},
	}

	kratos := kratos.NewAPIClient(cfg)
p
and the other admin endpoints work?
j
Copy code
identity, _, err := self.kratos.IdentityApi.GetIdentity(ctx, owner.UserID).Execute()
this thing works for sure
I don't use any other APIs
p
hmm, maybe it's a bug with the SDK. Could you check the request headers? You should be able to get the details of the entire request from the response object.
j
Copy code
headers="map[Access-Control-Allow-Credentials:[true] Access-Control-Allow-Origin:[<https://api.zamianeo.pl>] Access-Control-Expose-Headers:[Cache-Control, Expires, Last-Modified, Pragma, Content-Length, Content-Language, Content-Type] Alt-Svc:[h3=\":443\"; ma=86400] Cf-Cache-Status:[DYNAMIC] Cf-Ray:[7f2fd3238ff94d86-FRA] Connection:[keep-alive] Content-Length:[139] Content-Type:[application/json] Date:[Mon, 07 Aug 2023 13:21:48 GMT] Ory-Network-Region:[euw] Server:[cloudflare] Set-Cookie:[__cflb=04dTofjtHwhfCny3TimBZbgWZXE933GcSf48Xrhs4P; SameSite=None; Secure; path=/; expires=Mon, 07-Aug-23 14:21:48 GMT; HttpOnly] Vary:[Origin,Origin]]"
DeleteIdentity is used from my backend service when user wants to remove his account
<http://github.com/ory/kratos-client-go|github.com/ory/kratos-client-go> v0.11.1
Should I update kratos client?
p
ah, yes. please use the github.com/ory/client-go instead of kratos-client-go. We use this for Ory network. https://github.com/ory/sdk/tree/master/clients/client/go#go-api-client-for-client
this might fix the problem you have
j
Will it work with kratos for local development?
p
Yes, but it will expose more API endpoints which might not exist
j
I updated and get exactly the same error
Copy code
"map[Access-Control-Allow-Credentials:[true] Access-Control-Allow-Origin:[<https://api.zamianeo.pl>] Access-Control-Expose-Headers:[Cache-Control, Expires, Last-Modified, Pragma, Content-Length, Content-Language, Content-Type] Alt-Svc:[h3=\":443\"; ma=86400] Cf-Cache-Status:[DYNAMIC] Cf-Ray:[7f30db9e8e19bb61-FRA] Connection:[keep-alive] Content-Length:[139] Content-Type:[application/json] Date:[Mon, 07 Aug 2023 16:22:21 GMT] Ory-Network-Region:[euw] Server:[cloudflare] Set-Cookie:[__cflb=04dTofjtHwhfCny3TimBZbgWZXE933GUZ4wK3v5NR9; SameSite=None; Secure; path=/; expires=Mon, 07-Aug-23 17:22:21 GMT; HttpOnly] Vary:[Origin,Origin]]"
p
I'd have to take a look. I know this sounds odd, but have you tried removing some of the headers (such as origin?) maybe it's being denied on this endpoint. Since cors is a browser based protocol, it doesn't make sense to have it in the backend.
Also I don't see the Authorization header in this log
j
No, nothing works. I removed all unneeded headers,
Origin
too, and it did nothing. I was using a custom domain so I replaced it with ory-generated and everything stopped working.
There were some problems with billing in my account 2 months ago, maybe it's connected.
Maybe I'm putting a bad url? I use my custom domain
@proud-plumber-24205
b
The Authorization contains a : after the bearer, which it shouldn’t AFAIK:
Copy code
"Authorization": "Bearer " + config.KratosToken,
j
I owe you guys another beer, thank you!
The worse thing is that I saw this, and "fixed" but didn't add a space so it couldn't work.
The beer is going to be big and cold
❤️ 1
b
No worries, I have a way harder time finding issues in my own code, when compared to other people’s code 😉 So sometimes a second pair of eyes makes all the difference