示例#1
0
文件: vkapi.py 项目: CSRedRat/vk4xmpp
	def confirm(self):
		"""
		Confirms the application and receives the token
		"""
		url = "https://oauth.vk.com/authorize/"
		values = {"display": "mobile", "scope": SCOPE,
			"client_id": APP_ID, "response_type": "token",
			"redirect_uri": "https://oauth.vk.com/blank.html"}

		token = None
		body, response = self.get(url, values)
		if response:
			if "access_token" in response.url:
				match = token_exp.search(response.url)
				if match:
					token = match.group(0)
				else:
					logger.error("token regexp doesn't match the url: %s", response.url)
					raise AuthError("Something went wrong. We're so sorry.")
			else:
				postTarget = webtools.getTagArg("form method=\"post\"", "action",
					body, "form")
				if postTarget:
					body, response = self.post(postTarget)
					token = token_exp.search(response.url).group(0)
				else:
					raise AuthError("Couldn't confirm the application!")
		return token
示例#2
0
	def confirm(self):
		"""
		Confirms the application and receives the token
		"""
		url = "https://oauth.vk.com/authorize/"
		values = {"display": "mobile", "scope": SCOPE,
			"client_id": APP_ID, "response_type": "token",
			"redirect_uri": "https://oauth.vk.com/blank.html"}

		token = None
		body, response = self.get(url, values)
		if response:
			if "access_token" in response.url:
				match = token_exp.search(response.url)
				if match:
					token = match.group(0)
				else:
					logger.error("token regexp doesn't match the url: %s", response.url)
					raise AuthError("Something went wrong. We're so sorry.")
			else:
				postTarget = webtools.getTagArg("form method=\"post\"", "action",
					body, "form")
				if postTarget:
					body, response = self.post(postTarget)
					token = token_exp.search(response.url).group(0)
				else:
					raise AuthError("Couldn't confirm the application!")
		return token
示例#3
0
    def confirmThisApp(self):
        """
		Confirms your application and receives the token
		"""
        url = "https://oauth.vk.com/authorize/"
        values = {
            "display": "mobile",
            "scope": self.scope,
            "client_id": self.app_id,
            "response_type": "token",
            "redirect_uri": "https://oauth.vk.com/blank.html"
        }

        token = None
        body, response = self.RIP.get(url, values)
        if response:
            if "access_token" in response.url:
                token = token_exp.search(response.url).group(0)
            else:
                postTarget = webtools.getTagArg("form method=\"post\"",
                                                "action", body, "form")
                if postTarget:
                    body, response = self.RIP.post(postTarget)
                    token = token_exp.search(response.url).group(0)
                else:
                    raise AuthError("Couldn't execute confirmThisApp()!")
        self.token = token
示例#4
0
	def confirmThisApp(self):
		url = "https://oauth.vk.com/authorize/"
		values = {"display": "mobile",
				"scope": self.scope,
				"client_id": self.app_id,
				"response_type": "token",
				"redirect_uri": "https://oauth.vk.com/blank.html"}

		token = None
		body, response = self.RIP.get(url, values)
		if response:
			if "access_token" in response.url:
				token = response.url.split("=")[1].split("&")[0]
			else:
				postTarget = webtools.getTagArg("form method=\"post\"", "action", body, "form")
				if postTarget:
					body, response = self.RIP.post(postTarget)
					token = response.url.split("=")[1].split("&")[0]
				else:
					raise AuthError("Couldn't execute confirmThisApp()!")
		self.token = token
示例#5
0
文件: vk_api.py 项目: hidoba/vk4xmpp
	def api_login(self):
		url = "https://oauth.vk.com/authorize"
		values = { "display": "mobile",
				   "scope": self.scope,
				   "client_id": self.app_id,
				   "response_type": "token",
				   "redirect_uri": "https://oauth.vk.com/blank.html"
				   }

		token = None
		GET = self.http.get(url, params = values)
		getUrl = GET.url
		if "access_token" in getUrl:
			token = getUrl.split("=")[1].split("&")[0]
		else:
			POST = webtools.getTagArg("form method=\"post\"", "action", GET.text, "form")
			if POST:
				response = self.http.post(POST)
				token = response.url.split("=")[1].split("&")[0]
			else:
				raise authError("ApiError")
		self.token = token
示例#6
0
	def confirmThisApp(self):
		url = "https://oauth.vk.com/authorize"
		values = {"display": "mobile",
				"scope": self.scope,
				"client_id": self.app_id,
				"response_type": "token",
				"redirect_uri": "https://oauth.vk.com/blank.html"
				}

		token = None
		body, response = self.RIP.get(url, values)
		if response:
			if "access_token" in response.url:
				token = response.url.split("=")[1].split("&")[0]
			else:
				postTarget = webtools.getTagArg("form method=\"post\"", "action", body, "form")
				if postTarget:
					body, response = self.RIP.post(postTarget)
					token = response.url.split("=")[1].split("&")[0]
				else:
					raise AuthError("Couldn't execute confirmThisApp()!")
		self.token = token
示例#7
0
文件: vkapi.py 项目: alexeycv/vk4xmpp
	def confirmThisApp(self):
		"""
		Confirms your application and receives the token
		"""
		url = "https://oauth.vk.com/authorize/"
		values = {"display": "mobile",
				"scope": self.scope,
				"client_id": self.app_id,
				"response_type": "token",
				"redirect_uri": "https://oauth.vk.com/blank.html"}

		token = None
		body, response = self.RIP.get(url, values)
		if response:
			if "access_token" in response.url:
				token = token_exp.search(response.url).group(0)
			else:
				postTarget = webtools.getTagArg("form method=\"post\"", "action", body, "form")
				if postTarget:
					body, response = self.RIP.post(postTarget)
					token = token_exp.search(response.url).group(0)
				else:
					raise AuthError("Couldn't execute confirmThisApp()!")
		self.token = token