high-ram-25481
01/27/2023, 4:51 PMimport { OAuth2Api } from "@ory/client";
import axiosFactory from "axios";
const axios = axiosFactory.create({
withCredentials: true,
});
const oauth = new OAuth2Api(
new Configuration({
basePath: process.env.NEXT_PUBLIC_ORY_SDK_URL
accessToken: process.env.ORY_API_KEY,
}),
"",
axios
);
Then I setup Ory tunnel with
ory tunnel --dev --project <my_project_slug> <http://localhost:3000>
And set the env variable
NEXT_PUBLIC_ORY_SDK_URL=<http://localhost:4000>
Then when I use this oauth
instance to access ory network, it will throw this error
error: {
code: 401,
status: 'Unauthorized',
request: '4c5176ec-22b5-96fd-8b07-101af08359cc',
message: 'Access credentials are invalid'
}
But when I change the env var to
NEXT_PUBLIC_ORY_SDK_URL=<my_project_url>
The request will work. According to the Docs.
Only theneeds to access the Ory Tunnel. Administrative APIs likeFrontendApi
can be accessed directly from your project slug, although they also work via the Ory Tunnel. (<https://www.ory.sh/docs/getting-started/local-development#local-developmentIdentityApi
|ref>)It seems to have some bug here
// here is my ory cli version
❯ ory version
Version: v0.2.1
Git Hash: d1886fd9ec850e370c147a8ecb26f6e953943c9b
Build Time: 2023-01-07T17:43:52Z
_
This issue will further cause CSRF_TOKEN missing issue when develop locally with OAUTH2 authorization_code flowflat-flower-81031
01/27/2023, 5:16 PMflat-flower-81031
01/27/2023, 5:16 PM@ory/integrations
package has the proxy/tunnel built-in.high-optician-2097
high-ram-25481
01/27/2023, 5:33 PMAlso, if you are using Next, thepackage has the proxy/tunnel built-in.@ory/integrations
@ory/integration
is hard to work with. I bump into this issue when try to social login with the nextjs example
https://ory-community.slack.com/archives/C012RJ2MQ1H/p1673871819489039?thread_ts=1673846996.935599&cid=C012RJ2MQ1H
So I switch to implement my own logic that this comment suggestedhigh-ram-25481
01/27/2023, 5:39 PMhigh-ram-25481
01/28/2023, 11:27 AMhigh-ram-25481
02/01/2023, 7:38 AMhigh-optician-2097
high-ram-25481
02/02/2023, 1:13 AMhigh-optician-2097
high-optician-2097
high-optician-2097
high-ram-25481
02/02/2023, 11:47 AMhigh-ram-25481
02/02/2023, 11:49 AMhigh-optician-2097
high-optician-2097
high-ram-25481
02/02/2023, 2:57 PM