Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Note

The content of this page applies to all the methods of MailUp REST API except for the Transactional APIs, which do not use OAUTH 2.0

...

MailUp authorization server supports only "Authorization code grant flow" and "Resource owner password grant" (aka "Password flow")

Authorization code grant (recommended) 

...

Anchor
http401unauthorized
http401unauthorized
In case of expired token you need to refresh it (HTTP 401)

in In case of HTTP 401 error you need to refresh the authorization token, getting a new one by means of the refresh token. Please note that also the refresh token "refresh token" is renewed with the request and the new value is returned in the response body.  

Code Block
titleRefresh the access token
// #1 When resource access fails because token is expired
curl -H "Authorization:Bearer MYACCESSTOKEN" /
		-H "Content-Type:application/x-www-form-urlencoded" MYRESOURCEENDPOINT 
Response:{"ErrorCode":"401","ErrorDescription":"Authorization error: Access token is expired","ErrorName":"Unauthorized","ErrorStack":null}
 
// #2 First you need to get a new token
curl -X POST -d "client_id=MYCLIENTID&client_secret=MYCLIENTSECRET&refresh_token=MYREFRESHTOKEN&grant_type=refresh_token" /
		https://services.mailup.com/Authorization/OAuth/Token
Response:{	"access_token":"MYNEWACCESSTOKEN","expires_in":3600,"refresh_token":"MYNEWREFRESHTOKEN"}

 
// #3 Then you can successfully access to the resource by using the new token
curl -H "Authorization:Bearer MYNEWACCESSTOKEN" /
		-H "Content-Type:application/x-www-form-urlencoded" MYRESOURCEENDPOINT 

...