# Error when requesting Trello access token response{code=400, message='Bad Request', body='null',

**URL:** <https://community.developer.atlassian.com/t/error-when-requesting-trello-access-token-response-code-400-message-bad-request-body-null/44737>\
**Category:** Trello\
**Created:** [January 26, 2021, 8:13pm UTC](https://community.developer.atlassian.com/t/error-when-requesting-trello-access-token-response-code-400-message-bad-request-body-null/44737 "2021-01-26T20:13:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![TomDelGiudice1](https://avatars.discourse-cdn.com/v4/letter/t/74df32/32.png) [@TomDelGiudice1](https://community.developer.atlassian.com/u/TomDelGiudice1)\
**Post date:** [January 26, 2021, 8:13pm UTC](https://community.developer.atlassian.com/t/error-when-requesting-trello-access-token-response-code-400-message-bad-request-body-null/44737/1 "2021-01-26T20:13:31Z")

</div>

Trying to run the scribejava library from GitHub to run a simple get from Trello Rest API  
I Included the KEY and KEY Secret Tokens then I requested the access Token.

I tried the following example in eclipse: scribejava/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/TrelloExample.java / .

I used these jars:  
scribejava-apis-8.1.0.jar  
scribejava-core-8.1.0.jar

I only modified these lines with codes I grabbed from the Trello website.  
private static final String API\_KEY = “your\_api\_key”;  
private static final String API\_SECRET = “your\_api\_secret”;  
This data was used successfully in POSTMAN to fetch the “me” data from Trello via Rest.

I see that my POST to get an access token we returned with a {code=400, message=‘Bad Request’} response.  
The following code is from the the latest version of scribejava api. (scribejava-8.1.0)

Here is the code involved in the error:  
(Code from OAuth10aService.java)  
final OAuthRequest request = prepareAccessTokenRequest(requestToken, oauthVerifier);  
try (Response response = execute(request)) {  
return api.getAccessTokenExtractor().extract(response);

(Values from Debug)  
requestToken = com.github.scribejava.core.model.OAuth1RequestToken@a\*\*\*\*\*\*\*  
oauthVerifier = [https://trello.com/1/OAuthAuthorizeToken?oauth\_token=](https://trello.com/1/OAuthAuthorizeToken?oauth_token=)\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

(Code from OAuth10aService.java)  
return api.getAccessTokenExtractor().extract(response);

Values from Debug)  
request= @request(POST [https://trello.com/1/OAuthGetAccessToken](https://trello.com/1/OAuthGetAccessToken))

response{code=400, message=‘Bad Request’, body=‘null’,  
headers={null=HTTP/1.1 400 Bad Request,  
X-Dns-Prefetch-Control=off,  
Server=globaledge-envoy,  
Access-Control-Allow-Origin=\*,  
Access-Control-Allow-Methods=GET,  
PUT, POST, DELETE,  
X-Permitted-Cross-Domain-Policies=none, Referrer-Policy=strict-origin-when-cross-origin,  
X-Frame-Options=DENY, Strict-Transport-Security=max-age=63072000;  
preload, Access-Control-Expose-Headers=x-rate-limit-api-key-interval-ms,  
x-rate-limit-api-key-max, x-rate-limit-api-key-remaining,  
x-rate-limit-api-token-interval-ms,  
x-rate-limit-api-token-max, x-rate-limit-api-token-remaining,  
X-Trello-Environment=Production, X-Trello-Version=1.2333.0,  
Surrogate-Control=no-store, Content-Length=15,  
}}

---

<div class="post-metadata">

**Author:** ![bentley](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/bentley/32/36116_2.png) [@bentley](https://community.developer.atlassian.com/u/bentley)\
**Post date:** [January 29, 2021, 3:16pm UTC](https://community.developer.atlassian.com/t/error-when-requesting-trello-access-token-response-code-400-message-bad-request-body-null/44737/2 "2021-01-29T15:16:26Z")

</div>

> [@TomDelGiudice1](#):
>
> private static final String API\_SECRET = “your\_api\_secret”;  
> This data was used successfully in POSTMAN to fetch the “me” data from Trello via Rest.

This leads me to believe that you’re using a Trello Token instead of the App Secret. An App Secret can not be used to make an API request by itself.

The App Secret that you need for OAuth can be found _at the bottom_ of [https://trello.com/app-key](https://trello.com/app-key).

---

<div class="post-metadata">

**Author:** ![TomDelGiudice1](https://avatars.discourse-cdn.com/v4/letter/t/74df32/32.png) [@TomDelGiudice1](https://community.developer.atlassian.com/u/TomDelGiudice1)\
**Post date:** [January 29, 2021, 7:25pm UTC](https://community.developer.atlassian.com/t/error-when-requesting-trello-access-token-response-code-400-message-bad-request-body-null/44737/3 "2021-01-29T19:25:40Z")

</div>

I used the API\_SECRET token from the bottom of the page.  
Please advise.

---

<div class="post-metadata">

**Author:** ![bentley](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/bentley/32/36116_2.png) [@bentley](https://community.developer.atlassian.com/u/bentley)\
**Post date:** [January 29, 2021, 8:00pm UTC](https://community.developer.atlassian.com/t/error-when-requesting-trello-access-token-response-code-400-message-bad-request-body-null/44737/4 "2021-01-29T20:00:52Z")

</div>

> [@TomDelGiudice1](#):
>
> This data was used successfully in POSTMAN to fetch the “me” data from Trello via Rest.

And you were able to make a request to `/1/members/me` and get back data with it?

---

<div class="post-metadata">

**Author:** ![TomDelGiudice1](https://avatars.discourse-cdn.com/v4/letter/t/74df32/32.png) [@TomDelGiudice1](https://community.developer.atlassian.com/u/TomDelGiudice1)\
**Post date:** [January 29, 2021, 8:28pm UTC](https://community.developer.atlassian.com/t/error-when-requesting-trello-access-token-response-code-400-message-bad-request-body-null/44737/5 "2021-01-29T20:28:41Z")

</div>

Yes, but when I used postman I was able to manually add the Access Token that I copied from the website. Without it it won’t work in Postman either. The issue I have in java/eclipse is posting the credentials and trying to receive an Access Token programmatically. I am using the trello sample code in the scribeJava library on GitHub.  
Trading the Request Token for an Access Token…  
final OAuth1AccessToken accessToken = service.getAccessToken(requestToken, oauthVerifier);  
The requestToken and oauthVerifier objects seem well formed with data.

---

<div class="post-metadata">

**Author:** ![TomDelGiudice1](https://avatars.discourse-cdn.com/v4/letter/t/74df32/32.png) [@TomDelGiudice1](https://community.developer.atlassian.com/u/TomDelGiudice1)\
**Post date:** [February 8, 2021, 2:19pm UTC](https://community.developer.atlassian.com/t/error-when-requesting-trello-access-token-response-code-400-message-bad-request-body-null/44737/6 "2021-02-08T14:19:29Z")

</div>

I am now getting an error when posting a auth token to trello inorder to access the resource.

[https://trello.com/1/OAuthAuthorizeToken?oauth\_token=](https://trello.com/1/OAuthAuthorizeToken?oauth_token=)\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

**Invalid return\_url**

Please advise

---

<div class="post-metadata">

**Author:** ![bentley](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/bentley/32/36116_2.png) [@bentley](https://community.developer.atlassian.com/u/bentley)\
**Post date:** [February 8, 2021, 5:21pm UTC](https://community.developer.atlassian.com/t/error-when-requesting-trello-access-token-response-code-400-message-bad-request-body-null/44737/7 "2021-02-08T17:21:41Z")

</div>

> [@TomDelGiudice1](#):
>
> **Invalid return\_url**

That sounds like it is related to your API key’s allowed origins: [https://developer.atlassian.com/cloud/trello/guides/rest-api/authorization/#allowed-origins](https://developer.atlassian.com/cloud/trello/guides/rest-api/authorization/#allowed-origins)

Make sure that the URL you’re redirecting to is added to your API keys _allowed origins_. You can update the list of allowed origins at: [https://trello.com/app-key](https://trello.com/app-key)

---

<div class="post-metadata">

**Author:** ![TomDelGiudice1](https://avatars.discourse-cdn.com/v4/letter/t/74df32/32.png) [@TomDelGiudice1](https://community.developer.atlassian.com/u/TomDelGiudice1)\
**Post date:** [February 8, 2021, 10:24pm UTC](https://community.developer.atlassian.com/t/error-when-requesting-trello-access-token-response-code-400-message-bad-request-body-null/44737/8 "2021-02-08T22:24:11Z")

</div>

I am currently working off a laptop. The only origin I could try was http://:80  
This yielded the same error.  
Please advise.

---

<div class="post-metadata">

**Author:** ![bentley](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/bentley/32/36116_2.png) [@bentley](https://community.developer.atlassian.com/u/bentley)\
**Post date:** [February 9, 2021, 1:40pm UTC](https://community.developer.atlassian.com/t/error-when-requesting-trello-access-token-response-code-400-message-bad-request-body-null/44737/9 "2021-02-09T13:40:50Z")

</div>

What is the route you are using on your local machine to test this out? That is the value that should probably be added to your allowed origins list.

---

<div class="post-metadata">

**Author:** ![TomDelGiudice1](https://avatars.discourse-cdn.com/v4/letter/t/74df32/32.png) [@TomDelGiudice1](https://community.developer.atlassian.com/u/TomDelGiudice1)\
**Post date:** [February 9, 2021, 7:06pm UTC](https://community.developer.atlassian.com/t/error-when-requesting-trello-access-token-response-code-400-message-bad-request-body-null/44737/10 "2021-02-09T19:06:44Z")

</div>

Yes, I am running a java program from eclipse. I returns the authorization link that I put into a browser or console. **[https://trello.com/1/OAuthAuthorizeToken?oauth\_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx](https://trello.com/1/OAuthAuthorizeToken?oauth_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx)**

I have tried (with and without the port 80) as an origin.  
http://my\_ip\_address:80  
http://my\_machine\_name.cusa.canon.com:80

Still get **Invalid return\_url**

Anything else I can try?

Thanks,

---

<div class="post-metadata">

**Author:** ![TomDelGiudice1](https://avatars.discourse-cdn.com/v4/letter/t/74df32/32.png) [@TomDelGiudice1](https://community.developer.atlassian.com/u/TomDelGiudice1)\
**Post date:** [February 16, 2021, 9:21pm UTC](https://community.developer.atlassian.com/t/error-when-requesting-trello-access-token-response-code-400-message-bad-request-body-null/44737/11 "2021-02-16T21:21:53Z")

</div>

I am on a laptop using eclipse. I tried the incoming VPN ip address and logged out of VPN and used the native ip address of my laptop. Both attempts failed. I also tries using port 80 an 443. Our network guy wanted to know if anything from your side can be blocking. Please advise.

Thanks,
