def get_officevideo_embed_code()

in officevideo/officevideo.py [0:0]


    def get_officevideo_embed_code(self, officevideo_url):

        embed_code = ''
        try:
            django_user_social = User.objects.get(id=self.xmodule_runtime.user_id).social_auth.get(provider='azuread-oauth2')
            if int(django_user_social.extra_data['expires_on']) < int(time.time()):
                django_user_social.refresh_token(load_strategy())
                django_user_social = User.objects.get(id=self.xmodule_runtime.user_id).social_auth.get(provider='azuread-oauth2')
            url = self.video_url
            parsed = urlparse.urlparse(url)
            query_params = urlparse.parse_qs(parsed.query)
            resp = requests.get("https://" + parsed.netloc + "/portals/hub/_api/VideoService/Channels('" + query_params['chid'][0] + "')/Videos('" + query_params['vid'][0] + "')/GetVideoEmbedCode",
                             headers={'Authorization': 'Bearer ' + django_user_social.tokens,
                                      'Content-Type': 'application/json;odata=verbose'})
            root = ET.fromstring(resp._content)
            embed_code = unicode(root.text, "utf-8")
        except:
            embed_code = '<a target="_blank" href="'+ officevideo_url +'">Office 365 Video</a>'

        return embed_code