gchoumos / mapillary

Tools to interact with the Mapillary API (v4)
MIT License
8 stars 0 forks source link

How to get the token and id? #4

Open Lay4949 opened 1 year ago

Lay4949 commented 1 year ago

Hello,I am a student. I want to know how to get the token and org_id.Thank you so much!

gchoumos commented 1 year ago

Hello @Lay4949 !

Thanks for your interest in this repository!

To use the Mapillary API, you have to create an account on the Mapillary platform, and then register an application that will be automatically assigned a token. This is the token that the scripts expect to have configured so that they are "allowed" to talk to the Mapillary API.

I suggest that you go through this section of the Mapillary documentation (link), which will shed some light on the steps to follow!

Let me know if you need to have further help after reading the above!

Assigning this ticket back to you for visibility :)

Thanks, George

kauevestena commented 1 year ago

hey @Lay4949 please don't send your token publicly, one can use it to do things on your name... In the specific case of mapillary I don't think that there's really bad things that could be done with it... It is a general security measure, because the token is the authorization for your account for the API, as your login/password is for the platform

gchoumos commented 1 year ago

Hey @Lay4949 ,

As @kauevestena pointed out (and thank you very much for that!), it is better to avoid having your token publicly available. I initially edited the comment, but the edit history is still public, so I eventually deleted it! Sorry about that, this is just as a pre-caution for you! :)

Will get back to you with a response soon!

Thanks a lot both of you!

George

Lay4949 commented 1 year ago

Hello,@gchoumos. Is there anything wrong with my operation to get the token? It doesn't seem to return the information it should have. I got authorization_code according to the tutorial and configured the parameters according to the following official format, but it seems that I didn't return the expected results. curl https://graph.mapillary.com/token \ -H "Content-Type: application/json" \ -H "Authorization: OAuth CLIENT_SECRET" \ -d' { "grant_type": "authorization_code", "code": "LONG_AUTHORIZATION_CODE", "client_id": CLIENT_ID }'

The following is what I used: curl https://graph.mapillary.com/token \^ -H "Content-Type: application/json" \^ -H "Authorization: MLY|**|*****" \^ -d'^ {^ "grant_type": "authorizationcode",^ "code": "code=AQCeBGRm2jvbYDF55VZlDplKd30ABOKAllaqcgk48TqbZ2L25BPl8qDMub4WzSbR1Ciw7xodwfCaXNhGOJB7sPJE9xHaaoIkZIEMFIBS5hBThJAtys6lnu07-DxCf5kWPsC5yWAPGP0QOiQiAa4GC2aDpr8eINP23JJUPpzhiM2rIRTkkl34uzus5H_QcNc0jEGizLEH9FddVUpafdoNFkZlBmMNKSYmyq7Lf3gWmAGVLuhLU5MXAL2Cx_nt249YCK7ShRlyzcsxGpY_D_cA8s1SfCsYktj8MA3aO6vaHdcQ",^ "client_id": ** }'

gchoumos commented 1 year ago

Hello @Lay4949 !

Is this an error that occurs through running any of the scripts provided in this repository? Or is this a standalone curl command that you are attempting to run?

Normally, if you configure your access_token (the one that looks like MLY|******|**********) in the settings.py file, the scripts should run with no issue.

If you are running a standalone curl, and not through the scripts, it will be a bit difficult for me to support you. Could you try doing this through the scripts, and by setting the "MLY" token in settings? It is the token item of the relevant dictionary, where a dummy value is provided by default.

SETTINGS = {
   ...
    'img_meta_out_file': 'img_meta_dataset.csv', # images with metadata
    'detections_out_file': 'img_detections_dataset.csv', # detections of images
    'token': 'MLY|1234567890123456|1234567890abcdef1234567890abcdef', <<<<<< Change this!
    'min_zoom': 13,
   ...

Hope that helps :)

George

Lay4949 commented 1 year ago

Thank you very much for reminding me.

Lay4949 commented 1 year ago

Sorry, I haven't got access_token yet. What I'm doing now is calls the token endpoint with the authorization code to exchange for the user access token.