Hi,
I registered a new app at https://www.lfs.net/account/api but I'm always getting `invalid_client` when trying to authenticate.
I tried with Postman, a python script and a php script. All three methods fail, so I'm guessing the app is not properly registered despite showing up as registered on the website?
Here's the python script I used:
And here's the php code I also tried from another forum post:
Any help appreciated
I registered a new app at https://www.lfs.net/account/api but I'm always getting `invalid_client` when trying to authenticate.
I tried with Postman, a python script and a php script. All three methods fail, so I'm guessing the app is not properly registered despite showing up as registered on the website?
Here's the python script I used:
from rauth import OAuth2Service
import json
client_id = ""
client_secret = ""
accessTokenUrl = "https://id.lfs.net/oauth2/access_token"
baseUrl = "https://id.lfs.net/"
service = OAuth2Service(
name="generatecardata",
client_id=client_id,
client_secret=client_secret,
access_token_url=accessTokenUrl,
authorize_url=accessTokenUrl,
base_url=baseUrl,
)
data = {
'grant_type': 'client_credentials',
}
session = service.get_auth_session(data=data, decoder=json.loads)
access_token = session.access_token
print(access_token)
And here's the php code I also tried from another forum post:
<?php
echo nl2br("Hello World\n");
// Request a Bearer token by using the client_credentials grant type.
// This requires client_id and client_secret.
// One can simply fetch that by POSTing those values. See below for example.
$accessTokenUrl = 'https://id.lfs.net/oauth2/access_token';
$accessTokenPost = [
'grant_type' => 'client_credentials',
'client_id' => '',
'client_secret' => '',
];
$context = stream_context_create([
'http' => [
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => http_build_query($accessTokenPost),
'ignore_errors' => true,
]
]);
$result = file_get_contents($accessTokenUrl, false, $context);
if ($result)
{
$json = json_decode($result);
print_r($json);
}
else
{
var_dump($http_response_header);
var_dump($result);
}
Any help appreciated