dtid30526 2019-03-25 16:21
浏览 46

如何使用新的microsoft graph api将用户登录到yii站点

I'm creating a site that needs an oauth authorization through microsoft. In yii/authclient there's only live client and it is not working anymore.

I tried to write my own but something goes wrong. As far as I understood my AuthAction doesn't see clientId and returns 404 exception without text. Here's my code of the auth client.

What I get What I get

AuthAction class method run (it's default) AuthAction class method run (it's default)

class Office365OAuth extends OAuth2
{
    public $authUrl = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize';
    public $tokenUrl = 'https://login.microsoftonline.com/common/oauth2/v2.0/token';
    public $apiBaseUrl = 'https://login.microsoftonline.com/common/oauth2/v1.0';

    public $scope = null;

    public function init()
    {
        parent::init();
        if ($this->scope === null)
        {
            $this->scope = 'https://graph.microsoft.com/User.Read';
        }
    }

    /**
     * Overrides default function to fix malformed url
     */
    public function getReturnUrl()
    {
        return $this->returnUrl;
    }

    protected function defaultName()
    {
        return 'office365';
    }

    protected function defaultTitle()
    {
        return 'Office365';
    }

    /**
     * For popup mode
     */
    protected function defaultViewOptions()
    {
        return [
            'popupWidth' => 800,
            'popupHeight' => 500,
        ];
    }

    /**
     * Gets new auth token to replace expired one.
     */
    protected function initUserAttributes()
    {
        return $this->api('me', 'GET');
    }
}

So, how can I authenticate through MS graph?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用