Closed armyofda12mnkeys closed 2 years ago
Hi @armyofda12mnkeys, I am unable to reproduce your error. Can you please share your app configuration files?
I guess I shouldn't share my exact client_id/tenant_name, so i blanked those out.
Here are my userflows:
and the files attached is my config, (minus the real client_id/tenant_name). config.json.txt authConfig.js.txt.
I tested again locally on my personal computer to rule out firewall issues at work and still get that issue: first i login via the popup: then i click the HelloAPI link which gives:
you can see the /token call gives a id_token and refresh_token as well:
Any idea what could be wrong by just looking at configuration?, Thanks!, Ari
@armyofda12mnkeys The issue is that you're not passing the correct scope to your authConfig.js file. Please copy the exact value of the scope exposed in the API, as shown below in the image.
Then past that value to apiHello.scopes object in the authConfig.js, the scope should look like https://yourtentant.onmicrosoft.com/<your-api-application-id>/<scope-name>
.
Hey, The value I have in the 'Expose an API' scope area, is the same as what i have in the authConfig.js. I just double-checked now my pasting the url from the Azure portal into Notepad++ to check. Note: The React tutorial recommended replacing the your-api-application-id part with some value like 'tasks-api' so I did that.
authconfig.js is in the middle part of the pic. I also put my config.js file at the bottom (which won't have the full url and just 'tasks.read' per git repo).
Any ideas?, Thanks!, Ari
Im sorry to use this thread to ask this question, but im using this implementation with the AppRoles, but is there a way i dont have to add People app roles in both for the Webapp and API under "Enterprise applications"
Hey, The value I have in the 'Expose an API' scope area, is the same as what i have in the authConfig.js. I just double-checked now my pasting the url from the Azure portal into Notepad++ to check. Note: The React tutorial recommended replacing the your-api-application-id part with some value like 'tasks-api' so I did that.
authconfig.js is in the middle part of the pic. I also put my config.js file at the bottom (which won't have the full url and just 'tasks.read' per git repo).
Any ideas?, Thanks!, Ari
@armyofda12mnkeys Your application configuration files look fine to me. The issue is that you're not receiving an access token by azure to send to the API. Your request need to have an access token as shown below:
Can you please ensure that you're adding the scopes in the SPA application registration and giving the scopes an admin consent?
Im sorry to use this thread to ask this question, but im using this implementation with the AppRoles, but is there a way i dont have to add People app roles in both for the Webapp and API under "Enterprise applications"
@Pmr-precure I am not sure which sample you're referring to, but I assume you're referring to React single-page application calling Node.js & Express web API using App Roles. You can create one application registration for both the API and the SPA and declare the App Roles once for both applications. We are currently working on updating the sample to do so. You can look at the following PR's readme and implement it in your scenario.
Please open a new thread so we can track your issue. Thanks
Hey @salman90, I think you got it! I now see the /hello call send the token and the page loads correctly now. I probably rushed too fast through the tutorial and did not add the custom 'expose an api' scopes to the API Permissions area. I think maybe I saw "My APIs" in the tutorial and got confused because my api scopes weren't in there, but now I see they are in this other "APIs my organization uses" tab, maybe because of organization settings/permissions or something.
Thanks so much @salman90!, Ari
If I may ask a side question before closing the ticket. Now that my app 'works', should it turn green on the main registration listing page: Thought it was kinda weird its just grey (some inactive status?) and other apps there are green (active status?).
@armyofda12mnkeys No worries, I am happy to help. The colors are randomly generated if you do not upload a logo image for the app.
Issue
getting "Status Code: 401 Unauthorized" from /hello in Chrome In the API console, i see:
I do see right before /hello is called, i see /token is called and it does return a token like:
So why isn't it passing it along to /hello?
like /hello has a authorization token like so: authorization: Bearer and im guessing it should have a value like: authorization: Bearer eyJ0eX
Believe I setup everything according to spec in the Azure AD B2C settings for the App/Registration/UserFlows, and configured the config.js and authConfig.js with the simple updates mentioned in the tutorial as well.
This issue is for the sample
This issue is for a
Minimal steps to reproduce
Any log messages given by the failure
Expected/desired behavior
Browser and version
Thanks! We'll be in touch soon.