Skip to content
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

Bearer + token in JS not working #5

Closed
Chloe-blue opened this issue May 7, 2019 · 1 comment
Closed

Bearer + token in JS not working #5

Chloe-blue opened this issue May 7, 2019 · 1 comment
Labels
api plugin solved Help for issue given

Comments

@Chloe-blue
Copy link

Chloe-blue commented May 7, 2019

Describe the bug
Hello Arcadier,
I have an issue with JS. I used the Authentication API, got the token, and added "Bearer" before it to use to authenticate with other API's, but it keeps saying "Authorisation was denied."

To Reproduce
Steps to reproduce the behavior:
This was my code:

var get_token = {
 "url": "https://" + baseURL + "/token",
 "method": "POST",
 "headers": {
   "Content-Type": "application/x-www-form-urlencoded"
 },
 "data": {
   "client_id": "",
   "client_secret": "",
   "grant_type": "client_credentials",
   "scope": "admin"
 }
};
	
$.ajax(get_token).done(function(admin_token) {
  token = "Bearer " + admin_token.access_token;
}

What am I doing wrong?
P.S: baseURL was already declared to be = inkit.sandbox.arcadier.io

@Arcadier Arcadier self-assigned this May 7, 2019
@Arcadier
Copy link
Collaborator

Arcadier commented May 7, 2019

Hey Chloe, after trying your code we think this might solve the issue:

token = "Bearer " + JSON.stringify(admin_token.access_token).replace(/"/g, '');

It removes any unwanted quotation marks.

@Arcadier Arcadier pinned this issue May 8, 2019
@Arcadier Arcadier added the solved Help for issue given label May 8, 2019
@Arcadier Arcadier removed their assignment Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api plugin solved Help for issue given
Projects
None yet
Development

No branches or pull requests

2 participants