JIRA application link token generation failure - jira

We are trying to use the JIRA application link for creating the token. But we are getting the error as 400 response
Traceback (most recent call last):
File "generate_access_token.py", line 30, in
request_token = oauth.fetch_request_token(REQUEST_TOKEN_URL)
File "/usr/lib/python2.7/site-packages/requests_oauthlib/oauth1_session.py", line 284, in fetch_request_token
token = self._fetch_token(url, **request_kwargs)
File "/usr/lib/python2.7/site-packages/requests_oauthlib/oauth1_session.py", line 368, in _fetch_token
raise TokenRequestDenied(error % (r.status_code, r.text), r)
requests_oauthlib.oauth1_session.TokenRequestDenied: Token request failed with code 400, response was 'oauth_parameters_absent=oauth_consumer_key&oauth_problem=parameter_absent'.
Can someone please help?

The error seems to explain that a value for oauth_consumer_key is not being passed.
The parameter_absent error means that you are not sending the required OAuth parameters to the actual endpoint.
Can you check if this is being passed correctly or if it is not being passed totally? Adding your code snippet should help others help you identify the issue quickly!
Hope this answers your question!

Related

HTTPS Get request with Micropython on a ESP8266 failing

apologies upfront for being a complete SSL noob.
I´m starting to work with Micropython and ran into a problem that with HHTPS requests. With the below code on an ESP8266MOD 12F I try to get some information from a test API, but all I get is an error.
import urequests as requests
import network
WIFI_SSID = "***********"
WIFI_PW = "************"
def connect_wifi(wlan, ssid, password):
if not wlan.isconnected():
print("\nConnecting...")
wlan.connect(ssid, password)
while not wlan.isconnected():
pass
print("Wifi connected")
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
connect_wifi(wlan, WIFI_SSID, WIFI_PW)
if not wlan.isconnected():
connect_wifi(wlan, WIFI_SSID, WIFI_PW)
else:
url = "http://api.coindesk.com/v1/bpi/currentprice.json"
r = requests.get(url)
print(r.text)
The error I get is:
Traceback (most recent call last):
File "<stdin>", line 25, in <module>
File "urequests.py", line 116, in get
File "urequests.py", line 62, in request
OSError: [Errno 107] ENOTCONN
My original attempt was to get to the Telelgram Bot API so I can send Telegram messages from my IoT devices. If I use an URL for the Telelgram API in the form of
url = "https://api.telegram.org/bot*****:***********/sendMessage?text=Klingel&chat_id=*****"
I get a different error which is
Traceback (most recent call last):
File "<stdin>", line 25, in <module>
File "urequests.py", line 116, in get
File "urequests.py", line 60, in request
OSError: [Errno 103] ECONNABORTED
When changing the Coindesk URL to HTTP, everything works fine. Unfortunately the Telegram API does not accept HTTP requests.
I tried several different urequests libraries as the on e isntalles via pip seemed to be a bit dated. The one I´m currently trying I got from github here. My ESP is running the current firmware esp8266-20220618-v1.19.1 from micropython.org.
I searched the internet for 4 days now and did not find anything that helped me. Nevertheless there seem to be quite some people to managed to use SSL in this configuration. As I am a true beginner in this whole topic, any help would be appreciated.
Thanks
Marcus
After some deeper digging I found out that the problem was caused by my Adguard DNS server which blocked the Telegram API. I did not see it on my laptop because it used a different DNS server. Now that I fixed the DNS issue, I´m getting OSError -40 which seems to be a common problem with the axTLS library used in the ESP8266. At least that makes sense to me now.
Thanks Andy for the quick reply.,

AADSTS900144: The request body must contain the following parameter: 'grant_type'

I am trying to generate the Access_Token after generating the Authorization code using MS Graph API.
I am getting the following error (Screen shot below)
"error_description": "AADSTS900144: The request body must contain the following parameter: 'grant_type'.",
I see that grant_type is present. I checked the rest of the values to be without any spaces. Any ideas on what could be wrong here? I appreciate your support.
Thanks,
Could you please try once in graph explorer .

Getting permission Error while calling API method using valid oauth2 access token

I am trying to authenticate using bearer token.
When I am trying to call the api with valid oauth2.0 access token
https://**************/api/method/frappe.auth.get_logged_user
I am getting this error response.
{
"exc": "[\"Traceback (most recent call last):\\n File \\\"/home/frappe/frappe-bench/apps/frappe/frappe/app.py\\\", line 66, in application\\n response = frappe.api.handle()\\n File \\\"/home/frappe/frappe-bench/apps/frappe/frappe/api.py\\\", line 56, in handle\\n return frappe.handler.handle()\\n File \\\"/home/frappe/frappe-bench/apps/frappe/frappe/handler.py\\\", line 21, in handle\\n data = execute_cmd(cmd)\\n File \\\"/home/frappe/frappe-bench/apps/frappe/frappe/handler.py\\\", line 54, in execute_cmd\\n is_whitelisted(method)\\n File \\\"/home/frappe/frappe-bench/apps/frappe/frappe/handler.py\\\", line 64, in is_whitelisted\\n raise frappe.PermissionError('Not Allowed, {0}'.format(method))\\nPermissionError: Not Allowed, <function get_logged_user at 0x7f9c027a9c08>\\n\"]",
"_server_messages": "[\"{\\\"message\\\": \\\"Not permitted\\\"}\"]"
}
Hard to tell without the code base. But it looks like the
execute_cmd(..)
is raising a Permissions error. I think the problem is with the script itself running on that machine. i.e. Not necessarily the access token. But without code this is a guess. You could verify by manually running that script when logged into the machine with the same user/permissions as when running as a web server.

How to send a request to twitter using a proxy?

I'm trying to extract data from twitter. When I use the code in my home network, it works very well, but in my university we use a proxy server. So I need to configure the request. I'm not specialised on computer science, so I don't know how to modify the request.
I read the documentation in https://dev.twitter.com/ but I couldn't find a solution!
This is an exemple of code :
import tweepy
from tweepy import OAuthHandler
consumer_key = 'XXXXXXXXXX'
consumer_secret = 'XXXXXXXXXXXX'
access_token = 'XXXXXXXXXXXXXXXXXXXX'
access_secret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
api = tweepy.API(auth)
for status in tweepy.Cursor(api.home_timeline).items(100):
# Process a single status
print(status.text)
This is the error I got:
Traceback (most recent call last):
File "D:\formation\python\github tools\fbp.py", line 14, in <module>
for status in tweepy.Cursor(api.home_timeline).items(100):
File "C:\Anaconda\lib\site-packages\tweepy\cursor.py", line 197, in next
self.current_page = self.page_iterator.next()
File "C:\Anaconda\lib\site-packages\tweepy\cursor.py", line 108, in next
data = self.method(max_id=self.max_id, parser=RawParser(), *self.args, **self.kargs)
File "C:\Anaconda\lib\site-packages\tweepy\binder.py", line 245, in _call
return method.execute()
File "C:\Anaconda\lib\site-packages\tweepy\binder.py", line 189, in execute
raise TweepError('Failed to send request: %s' % e)
TweepError: Failed to send request: HTTPSConnectionPool(host='api.twitter.com', port=443): Max retries exceeded with url: /1.1/statuses/home_timeline.json (Caused by ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Authentification proxy requise',)))
You can add a proxy using the follow code:
api =tweepy.API(auth,proxy="127.0.0.1:1080")
It works on my computer. You can try to modify you code like this.

Newbie OAuth issue: Error when trying to use the PHPoAuthLib OAuth lib

I've got an issue using this OAuth lib when connecting with twitter:
https://github.com/Lusitanian/PHPoAuthLib
I'm using the following url to connect:
http://www.myserver.com/oauth/examples/twitter.php?go=go
I'm getting the following error:
Fatal error: Uncaught exception 'OAuth\Common\Http\Exception\TokenResponseException' with message 'file_get_contents(https://api.twitter.com/oauth/request_token): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized ' in /webDeploy/V2/sites/wandexBB/oauth/src/OAuth/Common/Http/Client/StreamClient.php:75 Stack trace: #0 /webDeploy/V2/sites/wandexBB/oauth/src/OAuth/OAuth1/Service/AbstractService.php(52): OAuth\Common\Http\Client\StreamClient->retrieveResponse(Object(OAuth\Common\Http\Uri\Uri), Array, Array) #1 /webDeploy/V2/sites/wandexBB/oauth/examples/twitter.php(59): OAuth\OAuth1\Service\AbstractService->requestRequestToken() #2 {main} thrown in /webDeploy/V2/sites/wandexBB/oauth/src/OAuth/Common/Http/Client/StreamClient.php on line 75
It looks like the request body is empty.
I see in the code the following params are being used:
$_GET['oauth_token'],
$_GET['oauth_verifier'],
What are these params? I see in my twitter account I have various tokens available after I created my app on twitter, is it something to do with that?
I'm lost :/ This could be the wrong approach altogether.
Can anyone help with this?
Thanks in advance.
This lib seems to have a bug relating to the twitter implementation. Now using a different lib and got that going much more easily:
https://github.com/sudocode/ohmy-auth

Resources