A
A
Alexander N++2014-04-29 11:44:10
Adobe Flash
Alexander N++, 2014-04-29 11:44:10

How to get access_token VK and FB (FLASH AIR)?

How to get access_token VK, FB from under AIR application?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander N++, 2014-05-02
@sanchezzzhak

As always, I have to answer my own question...
I had to do everything in a native way, because the developers do not want to make an ANE extension for AIR applications.
FOR VK
Create a sprite object or a button on click, make an event
Create 2 constants for the link to quickly edit the config...

const 
  VK_APP_ID:Number = 1,
  VK_URL_AUTH:String = 'https://oauth.vk.com/authorize?client_id='+VK_APP_ID+'&scope=offline&redirect_uri=https://oauth.vk.com/blank.html=mobile&response_type=token';

private function onBtnVKClick(event:Event):void 
{
  stage_web_view = new StageWebView();
  stage_web_view.stage = stage;
  stage_web_view.viewPort = new Rectangle(25, 25, APP_WIDTH - 50, APP_HEIGHT -50);
  stage_web_view.addEventListener(LocationChangeEvent.LOCATION_CHANGE, onCheckAuthVK);
  stage_web_view.loadURL( VK_URL_AUTH );
}

StageWebView is a browser in an AIR application that works on almost all devices.
Let's create a callback for the LocationChangeEvent.LOCATION_CHANGE event,
which is triggered when the address changes.
private function onCheckAuthVK(event:Event)
{
  var url:String = stage_web_view.location;
  
  //url = 'https://oauth.vk.com/blank.html#access_token=.....&expires_in=0&user_id=...';
  if ( url.indexOf('//oauth.vk.com/blank.html#') > 0)
  {
    var arr:Array = url.split('#'); trace('STR TOKEN', arr[1]);
    var url_varitable:URLVariables = new URLVariables(arr[1]);
    trace('access_token ', url_varitable['access_token'], url_varitable['user_id']);
  }
}

Here, in principle, we save all the received token to a file.
In FB principle, also, who will file the solution, comment on this answer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question