moenk
January 21, 2021, 10:24pm
1
Anybody managed to do client auth with API v3 and Python? Even Mapillary themselves use the old v2 login in their uploader.
I tried the usual thing here but it did not work:
https://requests-oauthlib.readthedocs.io/en/latest/oauth2_workflow.html#backend-application-flow
Some sample code to get the bearer would be great.
moenk
January 22, 2021, 12:36pm
2
I found out that the API v3 auth implementation is very limited and just allows web and mobile auth. So I did this as a workaround to gain the access token:
from oauthlib.oauth2 import MobileApplicationClient
from requests_oauthlib import OAuth2Session
client_id = 'd0FVV29VMDR6SUVrcV94cTdabHBoZzoxZjc2MTE1Mzc1YjMxNzhi'
token_url = "https://a.mapillary.com/v2/oauth/token"
redirect_uri = "https://geoclub.de/mapillary/oauth2.php"
auth_url = "https://www.mapillary.com/connect"
scopes = ['public:upload']
mobile = MobileApplicationClient(client_id)
oauth = OAuth2Session(client=mobile, redirect_uri=redirect_uri, scope=scopes)
authorization_url, state = oauth.authorization_url(url=auth_url)
print("State:", state)
print('Please go to %s and authorize access.' % authorization_url)
authorization_response = input('\nEnter the resulting callback URL:\n')
f = open("accesstoken3.conf", "w")
for line in authorization_response.split("&"):
This file has been truncated. show original
Maybe there will be a tiny uploader later to upload images to Mapillary with Python 3.