Connection.request_token: missing_code-error despite single tenant application
See original GitHub issueHi there! I’m trying to deal with microsoft graph api via O365. As far as I understand the usage of an Authorization Code is not necessary when dealing with single tenant applications. My code is the following:
credentials = ('client_id', 'client_secret')
scopes = ['http://graph.microsoft.com/Mail.Read']
protocol_graph = MSGraphProtocol()
scopes_graph = protocol_graph.get_scopes_for(scopes)
con = Connection(credentials, scopes=scopes_graph, tenant_id='tenant_id')
url, state = con.get_authorization_url()
con.request_token(url)
request_token gives me: Unable to fetch auth token. Error: (missing_code) Missing code parameter in response. despite there’s no need of a code since dealing with single tenant application.
I’m able to get a token via:
payload = {'client_id': 'client_id',
'client_secret': 'client_secret',
'grant_type': 'client_credentials',
'scope': 'Mail.Read'}
r = requests.get('https://login.microsoftonline.com/tenant_id/oauth2/token',
data=payload, headers={'Content-Type': 'application/x-www-form-urlencoded'})
token = json.loads(r.content)['access_token']
Is there a workaround to set the token manually without usage of request_token? Many thanks!
Issue Analytics
- State:
- Created 4 years ago
- Comments:28 (28 by maintainers)
Top Results From Across the Web
Single and multi-tenant apps in Azure AD - Microsoft Entra
In the Azure portal, you can configure your app to be single-tenant or multi-tenant by setting the audience as follows. Audience, Single/multi- ...
Read more >What is Single-Tenancy? How's it Different from ... - TechTarget
In single-tenancy architectures, a customer -- called a tenant -- will have a singular instance of a SaaS application dedicated to them. In...
Read more >Single Tenant vs Multi-Tenant Architecture - BMC Software
The architecture of a public cloud service can be shared across multiple tenants, whereas private cloud systems are dedicated for individual ...
Read more >SaaS: Single Tenant vs Multi-Tenant - What's the Difference?
Each customer shares the software application and also shares a single database. Each tenant's data is isolated and remains invisible to other ...
Read more >Single-Tenant vs Multi-Tenant: Which One to Go With? | Dialpad
Why choose a multi-tenant architecture SaaS application? ... when the software is installed locally (although you won't have access to the underlying code)....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you very much @teamoo
With tenant = ‘common’ I get the following exception:
Unable to fetch auth token. Error: (unauthorized_client) AADSTS700016: Application with identifier 'XXXX-XXXX-XXXXX-XXXXXX' was not found in the directory 'microsoft.com'. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant.
So it is clear that the tenant id is definitely needed.