OAuth 2 client credentials token received in postman but not in serverWhat are Bearer Tokens and token_type in OAuth 2?How to validate an OAuth 2.0 access token for a resource server?Sending JWT token in the headers with Postmannodejs oauth2 token regeneration help neededOAuth client credentials conceptes6 mongoose nested findById promiseCORS issue making AJAX request from React app > Node server > redirect to Google OAuth2 authOAuth2 (unsupported_grant_type) Invalid grant_type: client_credentialsWait for data from external API before making POST requestHow to send github OAuth data to client?
15% tax on $7.5k earnings. Is that right?
Does Doodling or Improvising on the Piano Have Any Benefits?
What is the English pronunciation of "pain au chocolat"?
Why does Carol not get rid of the Kree symbol on her suit when she changes its colours?
A variation to the phrase "hanging over my shoulders"
A Trivial Diagnosis
Why should universal income be universal?
What does Apple's new App Store requirement mean
Creating two special characters
US tourist/student visa
What's the name of the logical fallacy where a debater extends a statement far beyond the original statement to make it true?
How could a planet have erratic days?
Is there a RAID 0 Equivalent for RAM?
Shouldn’t conservatives embrace universal basic income?
Which Article Helped Get Rid of Technobabble in RPGs?
Has the laser at Magurele, Romania reached a tenth of the Sun's power?
What (the heck) is a Super Worm Equinox Moon?
What is Cash Advance APR?
Does "he squandered his car on drink" sound natural?
Is there a nicer/politer/more positive alternative for "negates"?
Why can't the Brexit deadlock in the UK parliament be solved with a plurality vote?
What is the difference between lands and mana?
Why is the Sun approximated as a black body at ~ 5800 K?
Multiplicative persistence
OAuth 2 client credentials token received in postman but not in server
What are Bearer Tokens and token_type in OAuth 2?How to validate an OAuth 2.0 access token for a resource server?Sending JWT token in the headers with Postmannodejs oauth2 token regeneration help neededOAuth client credentials conceptes6 mongoose nested findById promiseCORS issue making AJAX request from React app > Node server > redirect to Google OAuth2 authOAuth2 (unsupported_grant_type) Invalid grant_type: client_credentialsWait for data from external API before making POST requestHow to send github OAuth data to client?
anyone can help me as I'm stuck to get an tokken from:
https://www.parcel2go.com/api/docs/articles/intro.html
Example Token Request:
POST /auth/connect/token HTTP/1.1
Host: sandbox.parcel2go.com
User-Agent: insomnia/5.14.6
Content-Type: application/x-www-form-urlencoded
Accept: */*
grant_type=client_credentials
&scope=public-api%20payment
&client_id=<client_id>
&client_secret=<client_secret>
Here is a photo from postman where all is working fine:
I have 2 solutions:
Solution number 1:
Here is a server:
const express = require("express");
const app = express();
const ClientOAuth2 = require("client-oauth2");
const p2gAuth = new ClientOAuth2(
clientId: "52bec26d025a4b8db2248a90da1e455a:testing",
clientSecret: "testing123",
accessTokenUri: "https://sandbox.parcel2go.com/auth/connect/token",
scopes: ["public-api", "payment"]
);
app.get("/api/getToken", (req, res) =>
p2gAuth.credentials.getToken().then(function(user)
console.log(user); //=> accessToken: '...', tokenType: 'bearer', ...
);
);
app.listen(3001, () =>
console.log("Express server is running on localhost:3001")
);
I getting response:
(node:22703) UnhandledPromiseRejectionWarning: Error: Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method).
at getAuthError (/Users/mario/Documents/VS/mario-p2g/node_modules/client-oauth2/src/client-oauth2.js:121:15)
at /Users/Mario/Documents/VS/mario-p2g/node_modules/client-oauth2/src/client-oauth2.js:269:21
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:22703) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:22703) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Solution number 2:
Would someone explain me what to do and the best I would like to know how to use this in fetch request, what is wrong with that code:
const express = require("express");
const app = express();
const fetch = require("node-fetch");
app.get("/api/getToken", (req, res) =>
fetch("https://sandbox.parcel2go.com/auth/connect/token",
method: "POST",
headers:
"User-Agent": "insomnia/5.14.6",
"Content-Type": "application/x-www-form-urlencoded",
Accept: "*/*"
,
body:
grant_type: "client_credentials",
client_id: "52bec26d025a4b8db2248a90da1e455a:testing",
client_secret: "testing123",
scope: ["public-api", "payment"]
)
.then(response => response.json())
.then(body =>
if (body)
res.json(body);
else
res.json( error: "no body after respond" );
)
.catch(error =>
res.json(error);
console.log("Server failed to return data: " + error);
);
);
app.listen(3001, () =>
console.log("Express server is running on localhost:3001")
);
node.js express oauth-2.0
New contributor
add a comment |
anyone can help me as I'm stuck to get an tokken from:
https://www.parcel2go.com/api/docs/articles/intro.html
Example Token Request:
POST /auth/connect/token HTTP/1.1
Host: sandbox.parcel2go.com
User-Agent: insomnia/5.14.6
Content-Type: application/x-www-form-urlencoded
Accept: */*
grant_type=client_credentials
&scope=public-api%20payment
&client_id=<client_id>
&client_secret=<client_secret>
Here is a photo from postman where all is working fine:
I have 2 solutions:
Solution number 1:
Here is a server:
const express = require("express");
const app = express();
const ClientOAuth2 = require("client-oauth2");
const p2gAuth = new ClientOAuth2(
clientId: "52bec26d025a4b8db2248a90da1e455a:testing",
clientSecret: "testing123",
accessTokenUri: "https://sandbox.parcel2go.com/auth/connect/token",
scopes: ["public-api", "payment"]
);
app.get("/api/getToken", (req, res) =>
p2gAuth.credentials.getToken().then(function(user)
console.log(user); //=> accessToken: '...', tokenType: 'bearer', ...
);
);
app.listen(3001, () =>
console.log("Express server is running on localhost:3001")
);
I getting response:
(node:22703) UnhandledPromiseRejectionWarning: Error: Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method).
at getAuthError (/Users/mario/Documents/VS/mario-p2g/node_modules/client-oauth2/src/client-oauth2.js:121:15)
at /Users/Mario/Documents/VS/mario-p2g/node_modules/client-oauth2/src/client-oauth2.js:269:21
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:22703) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:22703) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Solution number 2:
Would someone explain me what to do and the best I would like to know how to use this in fetch request, what is wrong with that code:
const express = require("express");
const app = express();
const fetch = require("node-fetch");
app.get("/api/getToken", (req, res) =>
fetch("https://sandbox.parcel2go.com/auth/connect/token",
method: "POST",
headers:
"User-Agent": "insomnia/5.14.6",
"Content-Type": "application/x-www-form-urlencoded",
Accept: "*/*"
,
body:
grant_type: "client_credentials",
client_id: "52bec26d025a4b8db2248a90da1e455a:testing",
client_secret: "testing123",
scope: ["public-api", "payment"]
)
.then(response => response.json())
.then(body =>
if (body)
res.json(body);
else
res.json( error: "no body after respond" );
)
.catch(error =>
res.json(error);
console.log("Server failed to return data: " + error);
);
);
app.listen(3001, () =>
console.log("Express server is running on localhost:3001")
);
node.js express oauth-2.0
New contributor
add a comment |
anyone can help me as I'm stuck to get an tokken from:
https://www.parcel2go.com/api/docs/articles/intro.html
Example Token Request:
POST /auth/connect/token HTTP/1.1
Host: sandbox.parcel2go.com
User-Agent: insomnia/5.14.6
Content-Type: application/x-www-form-urlencoded
Accept: */*
grant_type=client_credentials
&scope=public-api%20payment
&client_id=<client_id>
&client_secret=<client_secret>
Here is a photo from postman where all is working fine:
I have 2 solutions:
Solution number 1:
Here is a server:
const express = require("express");
const app = express();
const ClientOAuth2 = require("client-oauth2");
const p2gAuth = new ClientOAuth2(
clientId: "52bec26d025a4b8db2248a90da1e455a:testing",
clientSecret: "testing123",
accessTokenUri: "https://sandbox.parcel2go.com/auth/connect/token",
scopes: ["public-api", "payment"]
);
app.get("/api/getToken", (req, res) =>
p2gAuth.credentials.getToken().then(function(user)
console.log(user); //=> accessToken: '...', tokenType: 'bearer', ...
);
);
app.listen(3001, () =>
console.log("Express server is running on localhost:3001")
);
I getting response:
(node:22703) UnhandledPromiseRejectionWarning: Error: Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method).
at getAuthError (/Users/mario/Documents/VS/mario-p2g/node_modules/client-oauth2/src/client-oauth2.js:121:15)
at /Users/Mario/Documents/VS/mario-p2g/node_modules/client-oauth2/src/client-oauth2.js:269:21
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:22703) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:22703) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Solution number 2:
Would someone explain me what to do and the best I would like to know how to use this in fetch request, what is wrong with that code:
const express = require("express");
const app = express();
const fetch = require("node-fetch");
app.get("/api/getToken", (req, res) =>
fetch("https://sandbox.parcel2go.com/auth/connect/token",
method: "POST",
headers:
"User-Agent": "insomnia/5.14.6",
"Content-Type": "application/x-www-form-urlencoded",
Accept: "*/*"
,
body:
grant_type: "client_credentials",
client_id: "52bec26d025a4b8db2248a90da1e455a:testing",
client_secret: "testing123",
scope: ["public-api", "payment"]
)
.then(response => response.json())
.then(body =>
if (body)
res.json(body);
else
res.json( error: "no body after respond" );
)
.catch(error =>
res.json(error);
console.log("Server failed to return data: " + error);
);
);
app.listen(3001, () =>
console.log("Express server is running on localhost:3001")
);
node.js express oauth-2.0
New contributor
anyone can help me as I'm stuck to get an tokken from:
https://www.parcel2go.com/api/docs/articles/intro.html
Example Token Request:
POST /auth/connect/token HTTP/1.1
Host: sandbox.parcel2go.com
User-Agent: insomnia/5.14.6
Content-Type: application/x-www-form-urlencoded
Accept: */*
grant_type=client_credentials
&scope=public-api%20payment
&client_id=<client_id>
&client_secret=<client_secret>
Here is a photo from postman where all is working fine:
I have 2 solutions:
Solution number 1:
Here is a server:
const express = require("express");
const app = express();
const ClientOAuth2 = require("client-oauth2");
const p2gAuth = new ClientOAuth2(
clientId: "52bec26d025a4b8db2248a90da1e455a:testing",
clientSecret: "testing123",
accessTokenUri: "https://sandbox.parcel2go.com/auth/connect/token",
scopes: ["public-api", "payment"]
);
app.get("/api/getToken", (req, res) =>
p2gAuth.credentials.getToken().then(function(user)
console.log(user); //=> accessToken: '...', tokenType: 'bearer', ...
);
);
app.listen(3001, () =>
console.log("Express server is running on localhost:3001")
);
I getting response:
(node:22703) UnhandledPromiseRejectionWarning: Error: Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method).
at getAuthError (/Users/mario/Documents/VS/mario-p2g/node_modules/client-oauth2/src/client-oauth2.js:121:15)
at /Users/Mario/Documents/VS/mario-p2g/node_modules/client-oauth2/src/client-oauth2.js:269:21
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:22703) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:22703) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Solution number 2:
Would someone explain me what to do and the best I would like to know how to use this in fetch request, what is wrong with that code:
const express = require("express");
const app = express();
const fetch = require("node-fetch");
app.get("/api/getToken", (req, res) =>
fetch("https://sandbox.parcel2go.com/auth/connect/token",
method: "POST",
headers:
"User-Agent": "insomnia/5.14.6",
"Content-Type": "application/x-www-form-urlencoded",
Accept: "*/*"
,
body:
grant_type: "client_credentials",
client_id: "52bec26d025a4b8db2248a90da1e455a:testing",
client_secret: "testing123",
scope: ["public-api", "payment"]
)
.then(response => response.json())
.then(body =>
if (body)
res.json(body);
else
res.json( error: "no body after respond" );
)
.catch(error =>
res.json(error);
console.log("Server failed to return data: " + error);
);
);
app.listen(3001, () =>
console.log("Express server is running on localhost:3001")
);
node.js express oauth-2.0
node.js express oauth-2.0
New contributor
New contributor
New contributor
asked 13 hours ago
MarioMario
362
362
New contributor
New contributor
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Mario is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55280142%2foauth-2-client-credentials-token-received-in-postman-but-not-in-server%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Mario is a new contributor. Be nice, and check out our Code of Conduct.
Mario is a new contributor. Be nice, and check out our Code of Conduct.
Mario is a new contributor. Be nice, and check out our Code of Conduct.
Mario is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55280142%2foauth-2-client-credentials-token-received-in-postman-but-not-in-server%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown