gpt4 book ai didi

Instagram 基本显示 API 错误 - 范围无效 : ['basic' ] OR Invalid redirect_uri

转载 作者:行者123 更新时间:2023-12-03 16:12:04 32 4
gpt4 key购买 nike

我正在使用 Magento 2.4.1,安装了社交登录扩展并在登录 Instagram 时出现以下错误,我正在使用混合身份验证库登录。

"error_type": "OAuthException", "code": 400, "error_message": "Invalidscope: ['basic']"}


您可以查看下面的截图,
Screenshot

Instagram.php

<?php
/*!
* HybridAuth
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
* (c) 2009-2012 HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
namespace Vendor\Module\Model\Providers;

/**
* Hybrid_Providers_Instagram (By Sebastian Lasse - https://github.com/sebilasse)
*/
class Instagram extends \Hybrid_Provider_Model_OAuth2
{
// default permissions
public $scope = "basic";

/**
* IDp wrappers initializer
*/
public function initialize()
{
parent::initialize();

// Provider api end-points
$this->api->api_base_url = "https://api.instagram.com/v1/";
$this->api->authorize_url = "https://api.instagram.com/oauth/authorize/";
$this->api->token_url = "https://api.instagram.com/oauth/access_token";
}

/**
* load the user profile from the IDp api client
*/
public function getUserProfile()
{
$data = $this->api->api("users/self/");

if ($data->meta->code != 200) {
throw new \Exception("User profile request failed! {$this->providerId} returned an invalid response.", 6);
}

$this->user->profile->identifier = $data->data->id;
$this->user->profile->displayName = $data->data->full_name ? $data->data->full_name : $data->data->username;
$this->user->profile->description = $data->data->bio;
$this->user->profile->photoURL = $data->data->profile_picture;

$this->user->profile->webSiteURL = $data->data->website;

$this->user->profile->username = $data->data->username;

return $this->user->profile;
}
/**
*
*/
public function getUserContacts()
{
// refresh tokens if needed
$this->refreshToken();

//
$response = array();
$contacts = array();
$profile = ((isset($this->user->profile->identifier))?($this->user->profile):($this->getUserProfile()));
try {
$response = $this->api->api("users/{$this->user->profile->identifier}/follows");
} catch (\Exception $e) {
throw new \Exception("User contacts request failed! {$this->providerId} returned an error: $e");
}
//

if (isset($response) && $response->meta->code == 200) {
foreach ($response->data as $contact) {
try {
$contactInfo = $this->api->api("users/".$contact->id);
} catch (\Exception $e) {
throw new \Exception("Contact info request failed for user {$contact->username}! {$this->providerId} returned an error: $e");
}
//
$uc = new \Hybrid_User_Contact();
//
$uc->identifier = $contact->id;
$uc->profileURL = "https://instagram.com/{$contact->username}";
$uc->webSiteURL = @$contactInfo->data->website;
$uc->photoURL = @$contact->profile_picture;
$uc->displayName = @$contact->full_name;
$uc->description = @$contactInfo->data->bio;
//$uc->email = ;
//
$contacts[] = $uc;
}
}
return $contacts;
}
}

Changing the scope "basic" to "user_profile,user_media", it showsdifferent error


enter image description here
更新
这是我的重定向 URI https://127.0.0.1/magento_241/sociallogin/social/callback/?hauth.done=Instagram

I'm not sure this could be the reason it's not working but green tickis not showing next to the Instagram Basic display as it is showing for Facebook Login.


Screenshot1

But my app is live here it shows live,


Screenshot2

Somehow if I managed to log in (after entering credentials) no matterwhat option do I choose in the below screenshot, it displays the error Oops, an error occurred. on this URL https://www.instagram.com/oauth/authorize/?client_id=MY_CLIENT_ID&redirect_uri=http%3A%2F%2F127.0.0.1%2Fmagento_241%2Fsociallogin%2Fsocial%2Fcallback%2F%3Fhauth.done&response_type=code&scope=basic


Screenshot2
如果有人有解决方案,请告诉我。

最佳答案

API has changed .授权的 URL 现在看起来不同了:

https://api.instagram.com/oauth/authorize?client_id=XXXXXX&redirect_uri=XXXXXX&scope=user_profile,user_media&response_type=code

只需在您的请求中交换它,它就会工作得很好。

关于Instagram 基本显示 API 错误 - 范围无效 : ['basic' ] OR Invalid redirect_uri,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59984334/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com