-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not authorized to access this customer #119
Comments
@muhaimincs You need to add the woocommerce-session token to the middleware along with the Authorization token, in your example it's commented out with not value. If you haven't authenticated the user with the Are you using the following versions for each plugin? |
The reason it was commented because I'm not sure what value should be stored in BTW, I don't have access to get the version number but I'm quite it just been installed for the wordpress version below |
OK now I have come to understand a bit on how the export const afterware = new ApolloLink((operation, forward) => {
return asyncMap(forward(operation), async (response) => {
const context = operation.getContext();
const { response: { headers } } = context;
const session = await headers.get("woocommerce-session");
const existingSession = await getSession();
if (session) {
if ("false" === session) {
removeSession();
} else if (existingSession !== session) {
storeSession(session);
}
}
return response;
});
});
const authMiddleware = new ApolloLink((operation, forward) => {
return asyncMap(forward(operation), async (response) => {
const token = await getToken();
const session = await getSession();
console.log('GET SESSION', session)
response.headers = {
'Authorization': `Bearer ${token}`,
'woocommerce-session': `Session ${session}`
};
return response
});
}) But it still won't work when I start to do mutation on add cart and if I refetch the get cart queries, it still empty. Where else did I missed? |
is it because I use |
I'm experiencing the same issue and providing the woocommerce token and the authentication token in the HTTP headers. Even took them to another tool to test outside of the website, and they aren't working.
Headers:
Error:
|
I think I may have the clue on what was wrong with the above code.
I used this and manually set the header to the response and this was wrong. So I did little modification to the way I sustain the session import { setContext } from "@apollo/client/link/context";
const asyncSessionLink = setContext(
request =>
new Promise((success, fail) => {
getSession().then(token => success({ headers: { Authorization: `Bearer ${token}` } }));
})
); I hope this may help the others in React-Native |
Hi
I'm trying to figure out how this plugin with React-Native. I believe I set it all right and I believe this has something to do with authorization. Appreciate if you guys can point me to the right direction on how to get it right with this query
and here is how I set up the apollo client (apollo.ts)
The text was updated successfully, but these errors were encountered: