Examples of codes for obtaining the authentication token
- Basic mode
cURL example
curl -X GET \ https://secure.lyra.com/marketplace-test/marketplaces/57595c55-b096-41d8-9287-b98640de3f25 \ -H 'Authorization: Basic YWRtaW46YWRtaW4=' -H 'Content-Type: application/json' -H 'cache-control: no-cache'
Example of a complete request in Python
import requests def get_marketplace_details(): uuid = "57595c55-b096-41d8-9287-b98640de3f25" url = f"https://secure.lyra.com/marketplace-test/marketplaces/{uuid}" return requests.get(url, auth=(login, password), headers={'content-type': 'application/json'})
Example of a request in .NET
var myURL = "https://secure.lyra.com/marketplace-test/orders?expand=items" HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(myURL); myHttpWebRequest.ContentType = "application/json"; myHttpWebRequest.Accept = "application/json"; myHttpWebRequest.Method = "post"; string authInfo = userName + ":" + userPassword; authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo)); myHttpWebRequest.Headers["Authorization"] = "Basic " + authInfo;
- Oauth2 mode:
cURL example
curl -X GET \ https://secure.lyra.com/marketplace-test/v1/marketplaces/57595c55-b096-41d8-9287-b98640de3f25 \ -H 'authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOi2lkIiA6ICJocXFZcjNkSlYycH...' \ -H 'cache-control: no-cache'
Example of a complete request in Python
import requests def get_marketplace_details(): uuid = "57595c55-b096-41d8-9287-b98640de3f25" url = f"https://secure.lyra.com/marketplace-test/v1/marketplaces/{uuid}" access_token = get_access_token() return requests.get(url, headers={'authorization': f"Bearer {access_token}", 'content-type': 'application/json'})