GithubHelp home page GithubHelp logo

Comments (12)

jasonjoh avatar jasonjoh commented on June 10, 2024

The error indicates that the auth flow wasn't found in the user's session. Basically, before the app redirects to the MS login page, it saves a "state" value in the session. It compares the state returned from the login process to make sure it matches the expected value. It's not finding the saved expected value to compare, and throwing that error.

Did you run python manage.py migrate? I believe Django uses the local database for storing sessions, and I don't think the database is initialized unless you run that command.

If you did run it, can you post your project on your GitHub? I'd be happy to take a look.

from msgraph-sample-pythondjangoapp.

msftbot avatar msftbot commented on June 10, 2024

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

from msgraph-sample-pythondjangoapp.

bjornpoort avatar bjornpoort commented on June 10, 2024

Works like a gem locally, but got the same issue on production (running on Heroku). If home page is refreshed you can view your calendar though

from msgraph-sample-pythondjangoapp.

jasonjoh avatar jasonjoh commented on June 10, 2024

@bjornpoort maybe this is relevant? https://stackoverflow.com/questions/52535488/django-sessions-not-working-as-expected-on-heroku

from msgraph-sample-pythondjangoapp.

jasonjoh avatar jasonjoh commented on June 10, 2024

@Sunag3 - check with your browser developer tools if there is a sessionid in the cookie. I had a colleague that had this same problem - turned out he was browsing to http://127.0.0.1:8000 instead of http://localhost:8000. Chrome would not set the cookie when using the IP address, which broke sessions. It works if you browse to http://localhost:8000.

cookie

from msgraph-sample-pythondjangoapp.

Sunag3 avatar Sunag3 commented on June 10, 2024

Hi, Thank you so much it works, problem was i was accessing through the ip address, it works fine with the localhost,
Also please suggest on below thing:

  1. How to add organizational tenant id
  2. What may be the changes if we have to do in production, i.e. in https environment and RHEL Server
  3. can we implement authentication for all the views, example it only shows for home view, what if we have more than one view.

from msgraph-sample-pythondjangoapp.

Sunag3 avatar Sunag3 commented on June 10, 2024

Uploading image.png…
Got This error after giving microsoft credentials

from msgraph-sample-pythondjangoapp.

jasonjoh avatar jasonjoh commented on June 10, 2024
  1. In oauth_settings.yml replace common in authority: "https://login.microsoftonline.com/common" with your tenant ID.
  2. Theoretically none to the code - you would need to update your app registration with the new URL to your callback in production.
  3. Sure. You really only need to check if the user is authenticated in your views (user.is_authenticated) and do what you want based on this value.

Your error image didn't upload.

from msgraph-sample-pythondjangoapp.

Sunag3 avatar Sunag3 commented on June 10, 2024

Thanks, currently the code is written in such a way that landing page is loaded and there has been given sign in button explicitly, but my requirement is, if i hit http://localhost:8000 it automatically redirects to Microsoft login page , then only it has to render my landing page, i have tried by giving login_required decorator to the home view but that doesn't worked

from msgraph-sample-pythondjangoapp.

Sunag3 avatar Sunag3 commented on June 10, 2024

Also i have downloaded your complete project and i tried to run, it gives time zone error

System check identified no issues (0 silenced).
January 16, 2021 - 17:08:43
Django version 3.1.4, using settings 'graph_tutorial.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[16/Jan/2021 17:09:00] "GET / HTTP/1.1" 200 2796
[16/Jan/2021 17:09:00] "GET /static/tutorial/app.css HTTP/1.1" 200 224
[16/Jan/2021 17:09:03] "GET /signin HTTP/1.1" 302 0
Sunag SJ
'timeZone'
[16/Jan/2021 17:09:14] "GET /callback?code=M.R3_BAY.b2a3d0e1-6382-192f-79fb-dc457b57d833&state=ydfFCvuEGYZctAiz HTTP/1.1" 302 0
[16/Jan/2021 17:09:15] "GET / HTTP/1.1" 200 2796

from msgraph-sample-pythondjangoapp.

Sunag3 avatar Sunag3 commented on June 10, 2024

hi
PFB link for Project Zip Files, it has 2 projects
https://github.com/Sunag3/AUTH_Projects.git

  • grap_tutorial : clone downloaded from your repository, its giving timezone key error and sign is not happening
  • graph_tutorial_old : not used caleder just created till implementation of Sign in -- its redirected to home page with error,

from msgraph-sample-pythondjangoapp.

jasonjoh avatar jasonjoh commented on June 10, 2024

Check and see if your user has a timeZone set. You can verify this in Graph Explorer. Do a GET https://graph.microsoft.com/v1.0/me/mailboxsettings and look for a timeZone property.

from msgraph-sample-pythondjangoapp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.