LinnSystems / LinnworksNetSDK

Linnworks.net Developers
26 stars 41 forks source link

AuthorizeByApplication #22

Closed DanielMiara closed 5 years ago

DanielMiara commented 5 years ago

Hello,

(https://apps.linnworks.net/Api/Method/Auth-AuthorizeByApplication)

I need help because the documentation is not clear to me. I created an application in LW and have Application ID and Secret as well. I want to get the token so I’ve sent POST data to https://api.linnworks.net/api/Auth/AuthorizeByApplication

CULR -- 'Host: api.linnworks.net', 'Connection: keep-alive', 'Accept: application/json, text/javascript, /; q=0.01', 'Origin: https://www.linnworks.net', 'Accept-Language: en', 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36', 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8', 'Referer: https://www.linnworks.net/', 'Accept-Encoding: gzip, deflate’,

POST -- 'applicationId' => $ApplicationId, 'applicationSecret' => $ApplicationSecret, 'userId' => ‘HOW TO GET IT?'

I’m getting string(85) "{"Code":"-","Message":"An internal error occurred. Please contact Linnworks support”}"

LinnSystems commented 5 years ago

Once an application is installed by an end-user using the installation link (found below the application ID and secret when editing an application), they are shown a token. In order to automatically receive this token without having to interact manually with the customer, there is an option to send a postback on successful installation.

https://help.linnworks.com/a/solutions/articles/7000007340-setting-up-a-basic-external-application

{ "modules": [{ "type": "ExternalApplication", "parameters": [{ "name": "PostbackUrl", "value": "http:\/\/www.google.co.uk?token=[{TOKEN}]&tracking=[{TRACKING}]" }] }] }

The token will be that same token that you can then use in AuthorizeByApplication to create a "session". Tracking is optional, and can be used to ensure which token is for which customer.

DanielMiara commented 5 years ago
  1. On installation, you will receive a token - static parameter that you will have to pass with application Id and Application Secret (both visible in dev portal) to this call http://apps.linnworks.net/Api/Method/Auth-AuthorizeByApplication Running the 'AuthorizeByApplication' call will then return you the 'API token' as 'Token'.

Thanks for the explanation. I have a problem because I can't see any token in my end-user account even if I edit the module.

LinnSystems commented 5 years ago

The developer portal also lists all users who have installed an application, along with their "permanent token", which is used in the AuthorizeByApplication call. This is visible in the main "Applications" view when you select an app, in the "Installs" grid at the bottom of the screen.